How do I import multiple text files into Access

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have several hundred text files (.asc) i need to import into my Access
table. Each file will be 1 record. There are no headers in the text files so
appending to the table isn't a problem. I'm just looking for a way to
automate the import so I don't have to do 1 at a time.

Thanks.
 
Here is something I got from Joe Falon in a previous post.
Watch for word wrap.

How to Import all Files in a Folder:

Private Sub btnImportAllFiles_Click()
'procedure to import all files in a directory and delete
them. 'assumes they are all the correct format for an ASCII
delimited import.

Dim strfile As String

ChDir ("c:\MyFiles")
strfile = Dir("FileName*.*")
Do While Len(strfile) > 0
DoCmd.TransferText acImportDelim, "ImportSpecName",
"AccessTableName",
"c:\MyFiles\" & strfile, True
'delete the file (consider moving it to an Archive folder
instead.)
Kill "c:\MyFiles\" & strfile
strfile = Dir
Loop

End Sub

Jim
 
Jim/Chris,

Thanks for the prompt response...

Please excuse my ignorance. I just jumped back into using Access after not
touching it since version 2.0

Is this a WMI script or something in need to "feed" into Access?

Thanks!
 
I need to do this with multiple access databases (approx 150!) but I need to
import 4 tables from each one to create one big master database. I presume I
can modify this code slightly to transferdatabase instead but I would
appeciate a little help please?
Thanks
Sue
 
Answered in another group.

I need to do this with multiple access databases (approx 150!) but I need to
import 4 tables from each one to create one big master database. I presume I
can modify this code slightly to transferdatabase instead but I would
appeciate a little help please?
Thanks
Sue
 
Back
Top