TransferText from Menu<>VBA

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

Guest

hello,
when importing csv file with menu option "Get External Data", I get my data
correctly loaded into my table. As the csv field headers contains '.' (dots),
I specify that the "first row doens't contain field names", and the header
row details are fully loaded. Then I delete the header row from the table.
When I do the same procedure from VBA, the header row is partially loaded :
some fields are left Null, which is ok, but Access creates an ImportError
table, which is not the case when using the menu option "Get External Data".

Anybody knows why this is happening ? Can I prevent these ImportError tables
to be created ?
Thx in advance
 
here is the code is use :
DoCmd.TransferText acImportDelim, , "mytable", .FoundFiles(i), False
DoCmd.RunSQL "DELETE * FROM mytable WHERE Field1 is null;"

Now I also delete the ImportErrors tables with :
DoCmd.DeleteObject acTable, Left(file_name, Len(file_name) - 4) &
"_ImportErrors"

file_name = "blabla.csv"

Thx for any help
 
I think creating in Import Specification will solve your problem. Do an
import by hand and when you get to the wizard, click on Advanced. Set up
your specifications the way you want the file imported. Then click Save As
and give the specification a name. Now in your VBA code, use the name you
assigned the specificaiton in your TransferText. It is the second argument.
 
I've already tried it, but then Access gives me an error msg ! I can't tell
what the msg is because I'm home now. I'll get back to office next tuesday. I
could give more info then.

thx anyway for the involvement
 
Let me know.

Nicodemus said:
I've already tried it, but then Access gives me an error msg ! I can't tell
what the msg is because I'm home now. I'll get back to office next tuesday. I
could give more info then.

thx anyway for the involvement
 
Back
Top