reading txt Files

  • Thread starter Thread starter TNGgroup
  • Start date Start date
T

TNGgroup

Hi,

I have an access database, a simple form, and on that form a button. I like
to open a txt file, look for specific data in the file, and save it into a
table ?

Can I do this and how ?

Thx

TNG
 
Here is an example:

Note:
I don't know how you put this data into txt file.
I use standard read for txt files.

Sub ReadTxtFile(sFile As String)
Dim nFile As Long
Dim strTemp As String

nFile = FreeFile

Open sFile For Input As #nFile
Do While Not EOF(nFile) 'to the end of file
Line Input #nFile, strTemp 'get 1 line
MsgBox strTemp 'view
'AddToTable strTemp 'add if you want
Loop 'loop, loop, loop
Close #nFile

End Sub

'procedure to add some data into table
Sub AddToTable(sWhat As String, Optional sTblName As
String = "a")
Dim strTemp As String

strTemp = "INSERT INTO " & sTblName & " (Field1)" & _
"VALUES (" & sWhat & ");"
CurrentDb.Execute stTemp

End Sub
 
Back
Top