Docmd.TransferText Error

P

pgilbert11

I am trying to setup a transfer command in VBA to transfer data from a txt
file to a database table.

The code keeps returning the error message:

Run-time error '2391'
Field 'F1' doesn't exist in destination table 'tbl1'

I cannot find any information on what it is looking for.
Can anyone please shed any light on this.

Oh also the table that is setup in access is based on this datafile.
I imported the file manually and created the table, then deleted the data
and tried to setup a VBA script to do it instead.

Thanks
Paul
 
S

strive4peace

the fact that Access assigned a field name of "F1" indicates
that perhaps you did not have field name specified in your
input file ... or you had fieldnames specified and one (or
more) of them has an illegal character, so it was converted
to "F1"

does your input file have column names in the first row?

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access

remote programming and training
strive4peace2006 at yahoo.com
 
P

pgilbert11

No there are no column names in the text file and all of the fields of the
access table have been set to text.
 
S

strive4peace

when Access imports the data, it has to name the fields
something, so it calls them F1, F2, F3, ... that is if you
import to a new table.

Since you are importing to a table that is already set up,
are you using an Import Specification?

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access

remote programming and training
strive4peace2006 at yahoo.com
 
P

pgilbert11

I am not using an import specification

I am using the command in its simplest form (command)(table)(file)
 
S

strive4peace

perhaps you should set up an import spec and specify it in
your statement...

here is one way to design a spec

1. File, Get External Data, Import
2. in the FileTypes combo, choose "Text Files"
3. navigate to text file
4. click IMPORT

on the next dialog box
5. click ADVANCED...
6. define your fields
7. to name the spec, click Save As...


Warm Regards,
Crystal
MVP Microsoft Access

remote programming and training
strive4peace2006 at yahoo.com
*
Have an awesome day ;)
 

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