Importing data via VBA

  • Thread starter Thread starter Adam
  • Start date Start date
A

Adam

I am trying to write some VBA code in Access 2000 to import data from a
delimited text file. In principle, this should be very simple, using
DoCmd.TransferText. However, I run into problems creating an import
specification. I would like to be able to do everything via VBA code, but I
can't find a VBA way to create the import specification in the first place:
I have only discovered how to do this manually.

My database will be created entirely in VBA code, and I don't want to let
the user play with things like the import wizard. Can I programmatically
create an import specification? Or can I programatically copy an import
specification already created in one database to another database? Or am I
going to have to use low-level file handling methods to read the external
data a line at a time?

I should point out that the external data is likely to be very simple, and I
don't need anything sophisticated for the import specification. All I really
need is a choice between tab and comma delimited and to specify whether the
first line contains field names.

Many thanks
 
Adam,

While you are designing the database, go ahead and manually import
your file. Save the import specification at that time. When you write
your code, you can reference the spec you saved.

Before you deploy your database, you can do whatever you want with the
table in which you imported your file. The specification will remain.

Hope this helps.
Rosco
 
Thanks for the suggestion, but that won't work, because the user will create
a new database through code. So I won't be able to manually import the file
in the database that the user will be using.

Adam
 
Back
Top