Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Importing Fix File Issue

Status
Not open for further replies.

Moxy1

Programmer
Aug 29, 2002
75
US
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
 
Use [!]Line[/!] Input

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top