Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / July 2007

Tip: Looking for answers? Try searching our database.

DateValue Format Question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JIT - 23 Jul 2007 20:02 GMT
I am currently importing a text document that has a supplier ship date field
in the format yyyy-mm-dd.  I have the following vb import code.

Option Compare Database
Function ImportPIC31022()
   Dim Path As String
   Dim File As String
   
   Path = "P:\111111Supply Chain\"
   File = "PIC31022.txt"
   ReadPIC31022File Path, File
   
End Function
Function ReadPIC31022File(FilePath As String, DataFile As String)
   Dim Inline As String, rst As DAO.Recordset
   On Error GoTo ErrHandler

   Set rst = CurrentDb.OpenRecordset("ASN Updated Data")
   
   Open FilePath + DataFile For Input As #1
   Line Input #1, Inline
   Do Until EOF(1)
       
           
           rst.AddNew
           rst!PDC = Left(Inline, 5)
           rst![Conveyance Number] = Mid(Inline, 79, 10)
           rst![Supplier Code] = Mid(Inline, 6, 5)
           rst![Part Number] = Mid(Inline, 13, 10)
           rst![Supplier Ship Date] = DateValue(Mid(Inline, 25, 10))
           rst![Shipper Number] = Mid(Inline, 37, 16)
           rst![ASN/ASC Bill of Lading] = Mid(Inline, 54, 17)
           rst.Update
   
       Line Input #1, Inline
   Loop
   
ErrHandler:
   Select Case Err
       Case 0
           Exit Function
       Case 55
           Close #1
           Resume
       Case Else
           MsgBox Err
           MsgBox Err.Description
           Resume
   End Select
End Function

I believe that when Access tries to import the text file, it reads the
dashes(-) and produces an error.  The error I am receiving is a "13" type
mismatch error.  Does anyone have any suggestions as to how to make Access
over-look these dashes?

Thank You,

Chad
Douglas J. Steele - 23 Jul 2007 20:07 GMT
Try:

   rst![Supplier Ship Date] = DateValue(Mid("#" & Inline, 25, 10 & "#"))

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

>I am currently importing a text document that has a supplier ship date
>field
[quoted text clipped - 55 lines]
>
> Chad
JIT - 23 Jul 2007 20:20 GMT
I still am receiving the same error.

> Try:
>
[quoted text clipped - 59 lines]
> >
> > Chad
Douglas J. Steele - 23 Jul 2007 20:51 GMT
Sorry, don't know what I was thinking!

That should have been:

rst![Supplier Ship Date] = DateValue("#" & Mid(Inline, 25, 10) & "#")

(of course, I'm assuming you've double checked that the date actually starts
in position 25)

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

>I still am receiving the same error.
>
[quoted text clipped - 63 lines]
>> >
>> > Chad
JIT - 23 Jul 2007 20:22 GMT
Still getting the same error.

> Try:
>
[quoted text clipped - 59 lines]
> >
> > Chad
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.