Dim lngCount As Long
Dim rs As DAO.Recordset
Dim strLineData As String
Dim strFileName As String
Dim strPrefix As String
Dim strDelete As String
strFileName = "C:\Documents and Settings\sbailey.SUMMIT\My Documents\Access\Misc\racedata.txt"
'Delete any existing records from the Temp table
strDelete = "Delete * From tblTemp;"
CurrentDb.Execute strDelete, dbFailOnError
'Set the record counter to 0
lngCount = 0
'Open the recordset
Set rs = CurrentDb.OpenRecordset("tblTemp")
'Open the file and read each line, inserting new records in the table as we go
Open strFileName For Input As #1
Do While Not EOF(1)
Line Input #1, strLineData
lngCount = lngCount + 1
If Mid(strLineData, 56, 1) = "T" Then
strPrefix = "T"
ElseIf Mid(strLineData, 58, 1) = " " Then
strPrefix = Mid(strLineData, 56, 2)
End If
With rs
.AddNew
!LineNumber = lngCount
!LinePrefix = strPrefix
!LineText = strLineData
.Update
End With
Loop
'Close the file and the recordset
Close #1
rs.Close