Reading text files:
I did the following to read a text file and then write into database. Have a common dialog control on the form to have a 'open file dialogbox' or in your case may be you can open the file directly - open "C:\mytextfile.prn" for input as #1
It opens the file for reading then with while condition, it reads until the end of the file, then with 'Line Input #1, sTemp' - it reads one line at a time, and then keeps the contents of that line into sTemp
Then it parses that sTemp into different fields and opens the recordset and writes the contents of those fileds into the table and then reads the next line. This goes on until it reaches the end of the file.
I did not have any problems of not reading commas and the text after that. I hope this helps you.
If you prefer to send me your file, you could do that. My e-mail is ravinuthala@un.org
cdlMain.Filter = "Text Files (*.txt)|*.txt|Data Files (*.dat)|*.dat|All Files|*.*"
cdlMain.ShowOpen
'MsgBox "You have selected " & cdlMain.FileName
Open cdlMain.FileName For Input As #1
While Not EOF(1)
Line Input #1, sTemp
If ((Left(sTemp, 2) <> "14"

) Then
'I am looking for some code 14 in the beginning
of the line. If it is not 14, then do nothing, skip to the next line
Else
ipos = 10
'sProjNo = Mid(sTemp, ipos, 7)
sFiscalShare = Val(Mid(sTemp, ipos, 2))
ipos = ipos + 2
sSeqNo = Mid(sTemp, ipos, 4)
ipos = ipos + 4
sItemNo = Mid(sTemp, ipos, 11)
sItemNoPre = Left(sItemNo, Len(sItemNo) - 6)
sItemNoPost = Right(sItemNo, 6)
sItemNo = sItemNoPre & "." & sItemNoPost
ipos = ipos + 12
sUnitMeasure = Mid(sTemp, ipos, 5)
ipos = ipos + 5
sUnitPrice = Mid(sTemp, ipos, 12)
sUnitPricePre = Left(sUnitPrice, Len(sUnitPrice) - 3)
sUnitPricePost = Right(sUnitPrice, 3)
sUnitPrice = sUnitPricePre & "." & sUnitPricePost
dUnitPrice = Val(sUnitPrice)
ipos = ipos + 13
sAuthQty = Mid(sTemp, ipos, 11)
sAuthQtyPre = Left(sAuthQty, Len(sAuthQty) - 2)
sAuthQtyPost = Right(sAuthQty, 2)
sAuthQty = sAuthQtyPre & "." & sAuthQtyPost
dAuthQty = Val(sAuthQty)
ipos = ipos + 47
sItemDes = Mid(sTemp, ipos)
If Trim(sItemNo) <> "." Then
Set rstItem = db.OpenRecordset("ITEM", dbOpenDynaset)
rstItem.AddNew
With rstItem
!Seq_Number = sSeqNo
!Item_Number = sItemNo
!Fiscal_Share = sFiscalShare
!Unit_of_Measure = sUnitMeasure
!Unit_Cost = dUnitPrice
!Orig_Auth_Quantity = dAuthQty
!Item_Descr = sItemDes
End With
rstItem.Update
End If
End If
Wend
End Sub