Hi,
I am using VBA code to upload a text file into an MS Access table (see code below). Everything is working fine, but the first line of the file is not being uploaded. It imports line 2 onwards. Does anyone have any ideas why?
Function Upload_SAP_AGR_USERS4()
Dim F As Long, sLine As String, A(0 To 8) As String
Dim db As Database, rs As Recordset
F = FreeFile
Open "C:\Users\Mims\Desktop\SAP_AGR_USERS4.txt" For Input As F
Line Input #F, sLine
Set db = CurrentDb
Set rs = db.OpenRecordset("dbo_Table_4")
Do While Not EOF(F)
Line Input #F, sLine
ParseToArray sLine, A()
rs.AddNew
rs(0) = A(0)
rs(1) = A(1)
rs(2) = A(2)
rs(3) = A(3)
rs(4) = A(4)
rs(5) = A(5)
rs(6) = A(6)
rs(7) = A(7)
rs(8) = A(8)
rs.Update
Loop
rs.Close
db.Close
Close #F
End Function
I am using VBA code to upload a text file into an MS Access table (see code below). Everything is working fine, but the first line of the file is not being uploaded. It imports line 2 onwards. Does anyone have any ideas why?
Function Upload_SAP_AGR_USERS4()
Dim F As Long, sLine As String, A(0 To 8) As String
Dim db As Database, rs As Recordset
F = FreeFile
Open "C:\Users\Mims\Desktop\SAP_AGR_USERS4.txt" For Input As F
Line Input #F, sLine
Set db = CurrentDb
Set rs = db.OpenRecordset("dbo_Table_4")
Do While Not EOF(F)
Line Input #F, sLine
ParseToArray sLine, A()
rs.AddNew
rs(0) = A(0)
rs(1) = A(1)
rs(2) = A(2)
rs(3) = A(3)
rs(4) = A(4)
rs(5) = A(5)
rs(6) = A(6)
rs(7) = A(7)
rs(8) = A(8)
rs.Update
Loop
rs.Close
db.Close
Close #F
End Function