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