Geoff Codd
Registered User.
- Local time
- Today, 15:25
- Joined
- Mar 6, 2002
- Messages
- 190
Hi there,
I have the following Code which currently seaches a text file and populates field 1 of my table with the City Name found
Public Sub findtext()
Dim buf As String
Dim lngPtr As Integer
Dim flgFound As String
Dim rs As DAO.Recordset
Dim db As DAO.database
Set db = CurrentDb
Set rs = db.openrecordset("tblCircuit_Information", dbopendynaset)
flgFound = "No"
Open "C:\temp.txt" For Input As #1
Line Input #1, buf
While Not EOF(1)
lngPtr = InStr(1, buf, "City: ")
If lngPtr > 0 Then
rs.AddNew
rs.Fields(1) = Mid(buf, lngPtr, 8)
rs.Update
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
Exit Sub
End If
Line Input #1, buf
Wend
MsgBox ("The line was not found")
Close #1
End Sub
What I need it to do is when it finds the second occurance of City put that value in Field 2.
What is the best way of doing this.
Thanks in advance
Geoff
I have the following Code which currently seaches a text file and populates field 1 of my table with the City Name found
Public Sub findtext()
Dim buf As String
Dim lngPtr As Integer
Dim flgFound As String
Dim rs As DAO.Recordset
Dim db As DAO.database
Set db = CurrentDb
Set rs = db.openrecordset("tblCircuit_Information", dbopendynaset)
flgFound = "No"
Open "C:\temp.txt" For Input As #1
Line Input #1, buf
While Not EOF(1)
lngPtr = InStr(1, buf, "City: ")
If lngPtr > 0 Then
rs.AddNew
rs.Fields(1) = Mid(buf, lngPtr, 8)
rs.Update
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
Exit Sub
End If
Line Input #1, buf
Wend
MsgBox ("The line was not found")
Close #1
End Sub
What I need it to do is when it finds the second occurance of City put that value in Field 2.
What is the best way of doing this.
Thanks in advance
Geoff