Text file Import

  • Thread starter Thread starter Matt V
  • Start date Start date
M

Matt V

I am using Access 2003 and I would like to import a text
file using VBA as a new table. I know how to use the
Docmd.TransferText command to import but the textfile does
not have field names in the first row and I did to be able
to name them either during the import process or change
the names form field 1, field 2, etc. after the import.
Any help you can provide would be greatly appreciated.

Thanks,
Matt
 
OTTOMH

1. Get a copy of the file and ADD field names to row 1.
2. Import the new copy using the wizard and check first row has field names
3. Fill out the whole spec.
4. On the last screen do NOT hit Finish. CLick Advanced instead.
5. Save the spec As...
6. Remember the name.
7. Finish.

The file should be imported to a table.
Check it out.
If it is OK, delete the table.

Re-import using DoCmd.TransferText
Use the spec name.
Set the parameter for first row has field names to Yes and re-import your
test file.
It should work perfectly.

Delete the table again.
Now tweak the code to say first does NOT have field names.
Use the original file.

Hopefully it works.
 
Back
Top