HI
im trying to read in csv file adn then import the data into a table.
Everything works so far but before the csv is added i remove the first 6 lines of it except for the first one.
How can i get just the ref no and append it to all records in the csv.
the ref no looks like
ref id: 1234
and then is the data to be included
i am usign the following to import the file
Dim fs As FileSystemObject
Set fs = New FileSystemObject
Dim txtInn As TextStream
Dim txtOut As TextStream
Dim lCounter As Long
Dim sText As String
Set txtInn = fs.OpenTextFile(strInputFileName, ForReading)
Set txtOut = fs.CreateTextFile("c:\test_2.txt", True)
Do While Not txtInn.AtEndOfStream
lCounter = lCounter + 1
sText = txtInn.ReadLine
txtOut.WriteLine sText
End If
If lCounter > 6 Then
txtOut.WriteLine sText
End If
Loop
txtInn.Close
txtOut.Close
Set txtInn = Nothing
Set txtOut = Nothing
Set fs = Nothing
DoCmd.TransferText acImportDelim, "matchdataimportspec", "match_data", "c:\test_2.txt", hasfieldnames - 0
Any ideas?/
cheers
Nick
im trying to read in csv file adn then import the data into a table.
Everything works so far but before the csv is added i remove the first 6 lines of it except for the first one.
How can i get just the ref no and append it to all records in the csv.
the ref no looks like
ref id: 1234
and then is the data to be included
i am usign the following to import the file
Dim fs As FileSystemObject
Set fs = New FileSystemObject
Dim txtInn As TextStream
Dim txtOut As TextStream
Dim lCounter As Long
Dim sText As String
Set txtInn = fs.OpenTextFile(strInputFileName, ForReading)
Set txtOut = fs.CreateTextFile("c:\test_2.txt", True)
Do While Not txtInn.AtEndOfStream
lCounter = lCounter + 1
sText = txtInn.ReadLine
txtOut.WriteLine sText
End If
If lCounter > 6 Then
txtOut.WriteLine sText
End If
Loop
txtInn.Close
txtOut.Close
Set txtInn = Nothing
Set txtOut = Nothing
Set fs = Nothing
DoCmd.TransferText acImportDelim, "matchdataimportspec", "match_data", "c:\test_2.txt", hasfieldnames - 0
Any ideas?/
cheers
Nick