TransferText Not Working - wants a Specification Name??

G

Guest

Hi,

I am trying to create a procedure that imports a Text file into a single
field of a table. I can do this correctly if I do it manually by using:

File
Get External Data
Import
I select my file "DMAImportData.Txt"
I click on Import
I let the wizard use Fixed Width
The only other thing I select is the table where I want the data to go.

This puts the entire txt file in one field called field1 and I get 36 rows
of data.

Then I tried to put this in a procedure.

I used the following command:

DoCmd.TransferText acImportFixed, , "DDAImportTest",
"L:\ImportDirectory\DDAImportData.Txt"

(Of course this is one complete line in my code and not split like it is
here.)

When I run this I get the following error:
Run Time Error 2511
The action or method requires a Specification Name argument.

I don't have and didn't use one in my manual import, what do I do here?

Also, do you know how I can prompt the user to use a browse or whatever to
locate their import file because they may have the import file in different
directories?

Thanks for any help you can give!
Kathy
 
G

Guest

Here is a link where you can find the code you need to present an Open File
dialog to the user to allow them to select the file to import:
http://www.mvps.org/access/api/api0001.htm

Next, you will have to create an Import Specification. To do that, go
through the import manually. When you get the Import Dialog, Click on the
Advanced button. Enter the information you need to get the file to import
like you want it. Now click on Save As and give it a name. That is the name
you will use in your TransferText.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top