Reputation: 1282
I am trying to import a text file in MSAccess Vba code as below
DoCmd.TransferText acImportDelim, "", "TableName", FileName, True, ""
The file am importing does not have a any headers in it. It is a comma delimited file with just data. The table has column names in it. Now i want to import that file in to this table. When i am trying to import that file using the above code its throwing an error Cannot find col 'X' in the table .(where X is the first row, first column of data in in the input file). Please suugest me some solution or a sample example. Your help is appreciated.
Upvotes: 0
Views: 7014
Reputation: 73303
If the file has no headers, you should be passing False for the HasFieldNames parameter instead of True:
expression.TransferText(TransferType, SpecificationName, TableName, FileName, HasFieldNames, HTMLTableName, CodePage)
...
HasFieldNames: Use True to use the first row of the text file as field names when importing, exporting, or linking. Use False to treat the first row of the text file as normal data.
Upvotes: 1