Automate text import

  • Thread starter Thread starter mate
  • Start date Start date
M

mate

Is there a way to automate the import of a text file with
a button or something else? The import would be updating
a table. I have tried linking the table but run into alot
of problems when writing queries. any help would be
greatly appreciated. thanks, mate.
 
I've used vb code to read a text file to update a table.
Then I created a macro to run the vb code and then a
command button to run the macro.

VB code ie. below:
Function ImportTable()
Dim dbs As DAO.Database, rst As DAO.Recordset
Dim strLine As String



Set dbs = CurrentDb

Open "yourfile.txt" For Input As #1

' Create a dynaset-type Recordset object based on
Material table.
Set rst = dbs.OpenRecordset("yourtablename")

'Add a new Record


Do While Not EOF(1)
Line Input #1, strLine

Loop

' Close text file.
MsgBox "Done!"

Close #1
rst.Close
Set dbs = Nothing

End Function
 
Back
Top