how do I import multiple text files to multiple tables

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

Guest

I have many text files I need to have imported to various tables depending on
the name of the file. For Example Sep02rev.txt needs to append and/or import
to the RevTbl, while Sep02exp.txt needs to append and/or import to the ExpTbl
 
shadow30082 said:
I have many text files I need to have imported to various tables depending on
the name of the file. For Example Sep02rev.txt needs to append and/or import
to the RevTbl, while Sep02exp.txt needs to append and/or import to the ExpTbl
 
I guess I'm still a little unclear. I'm trying to automate the enitre process
using Access VB. However, I'm very new to VB. Your link proves to be very
confusing. I don't really understand where to get what I need.
 
If you are new to VBA, this is going to be a challanging learning experience.
In the code you downloaded is a function named GetOpenFile. You can
experiment with it to see what it will do. To do this, in your immediate
window, type in x = GetOpenFile(). You will then see the Common Dialog box
where you can select a file. Once you have selected the file name, type in
?x Then you will see the full path and name of the file you selected in the
common dialog box.

Now, using that to import the files you want:

Dim varGetFileName as Variant

varGetFileName = GetOpenFile()

If varGetFileName <> "" Then ' An Empty string means the user canceled.
DoCmd.TransferText, acImportDelim, ,"MyTableName", varGetFileName,True
End If

You will need to insert your own table name and whatever arguments you need
for the transer.
With a little reading and study of the code you downloaded, you will see
that it is possilbe to identify the default directrory to look in for the
file name, and the default file name.
 
shadow30082,

Did you get this task figured out? I'm also trying to struggle through
importing to different tables based on different file names. I worked with
the code posted but even with some familiarity with VBA, it's a struggle.

Just checking if you got anywhere with your task and could lend some
guidance. Thanks much,
Marcia
 
Back
Top