J
JIT
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
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