TransferText in sub procedure

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

Guest

Hi guys,

I am trying to Import a text file into my Access 2000 table. It works no
problem if I do it manuallly: file, get external data, import but when I try
it from a sub I get an error mesage "Field (my file's 1st rec) doesn't exsist
in destination table". Am I missing an option or something?

DoCmd.TransferText acImportDelim, , "tblImportHold", strInputFileName, True
 
Are you including the field names in your txt/csv file? The True option in
the docmd line tells it to look for field names in your import file that
match the field names in your table.

I have a similar problem that I can't solve...
When I import records from my CSV file, it always seems to skip the first
record. But if I import through the menu, all is ok. My command line is as
follows:
DoCmd.TransferText acImportDelim, "CentrodataSpec", mytablename,
Me.txtFilename, False
I'm assuming that access is taking the first line as field names and
therefore not importing it, but of course I could be wrong. My CSV does not
include field names.

Can anybody shed any light on this for me... I'm using Access 97.

Thanks in advance

Dan
 
Hi Dan,

I recently had a similar problem, which I've solved but I'm using Access 2003. The default specification (variable 2) for text/csv import is set to have the first line as headers.

I've never worked out the official way of creating a specification file, however the easiest way I've found is to go to one of your tables, right click and export. On the drop down file select choose text. When you click export it will now start an export wizard select the settings you want for your importing file, including first line does not contain column headers. When you see an advanced tab (page 2 or 3 off the top of my head) select this and then choose Save As, choose a file name.

Once you've done this simply drop the new specification over CentrodataSpec in your variables.

Cheers

Greg
 
Back
Top