Hello,
I'd appreciate any help which is offered to my problem. I'm using
Acess 97.
I have a flat text file which lists names and addresses. Sometimes,
these can be 4 lines and sometimes 5 lines, with a blank line
separating them...
e.g.
Michael Wilde
Foxrock
Coolagh
Dublin
Tommy Williams
Ratoath
Lucan Drive
Finglas
Meath
etc...
I need to import this to a table whaich has 5 fields. When it is a 4
line address i need to leave the fifth field blank, and start back at
field 1 for the next record...
The following code works to a point. It does what i require but:
1. after each 5 line address it inserts a blank line
2. it omits the last entry of name and address
3. i get an error 62 - "input past end of file"
Function ImportFile()
Dim intImportFile As Integer
Dim strImportFile As String
Dim strTableName As String
Dim strInputLine As String
Dim dbs As Database
Dim rst As Recordset
strImportFile = "Y:\databases\milk\suppliers.txt"
strTableName = "TempTable"
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(strTableName, dbOpenDynaset)
intImportFile = FreeFile
Open strImportFile For Input As #intImportFile
'Do Until EOF(intImportFile)
While Not EOF(intImportFile)
rst.AddNew
Line Input #intImportFile, strInputLine
If Len(strInputLine) = 0 Then
GoTo cont
Else
rst!Line1 = strInputLine
End If
Line Input #intImportFile, strInputLine
If Len(strInputLine) = 0 Then
GoTo cont
Else
rst!Line2 = strInputLine
End If
Line Input #intImportFile, strInputLine
If Len(strInputLine) = 0 Then
GoTo cont
Else
rst!Line3 = strInputLine
End If
Line Input #intImportFile, strInputLine
If Len(strInputLine) = 0 Then
GoTo cont
Else
rst!Line4 = strInputLine
End If
Line Input #intImportFile, strInputLine
If Len(strInputLine) = 0 Then
GoTo cont
Else
rst!Line5 = strInputLine
End If
cont:
If EOF(intImportFile) Then GoTo end1
rst.Update
Wend
'loop
end1:
Close intImportFile
End Function
Any help would be sincerely appreciated...
Thank you....