I'm attempting to import a fixed length file with the following code. The issue that I've run in to is that if there is a comma in the line Access is treating it as a line return instead of a place holder. Any ideas:
Code:
Function ImportFile()
Dim recTable As Recordset
Dim strTheFile As String
Dim strFolderPath As String
Dim strTable As String
Dim strLine As String
strTheFile = "import.txt"
'
strFolderPath = "c:\"
strTable = "Import"
Set recTable = CurrentDb.OpenRecordset(strTable, dbOpenTable) 'Opens Acknowledgment table
Close #1
Open strFolderPath & strTheFile For Input As #1
TheBegining:
Do While Not EOF(1)
Reset:
Input #1, strLine
Debug.Print strLine
If Mid(strLine, 31, 15) = "S T A R T I T " Then
Do Until Mid(strLine, 3, 5) = "TOTAL"
Input #1, strLine
If Left(strLine, 11) <> "DESCRIPTION" Then
With recTable
.AddNew
![field1] = Left(strLine, InStr(strLine, "%"))
![field2] = Right(strLine, Len(strLine) - InStr(strLine, "%"))
.Update
End With
End If
Loop
End If
Loop
Close #1
recTable.Close
Set recTable = Nothing
Exit Function
DoCmd.SetWarnings True
End Function