DoCmd.TransferText acImportDelim

aziz rasul

Active member
Local time
Today, 09:55
Joined
Jun 26, 2000
Messages
1,935
I have adhoc csv files that I want to import into a new table "tblTemp".

Code:
DoCmd.TransferText acImportDelim, "", "tblTemp", strFile, True

If any columns in the csv file are not text and there is an invalid entry e.g. a Date column which could have an invalid date, the field in "tblTemp" will be a Data\Time type field but the invalid entry will not be shown and instead an ImportError table will give info regarding the record error.

How do I import the columns in the csv file so that all the data types in "tblTemp" are all TEXT irrespective the data types in the csv file?
 
try creating an import specification setting all fields to text - then save it with a name - e.g. txtimport

then modify your transfertext command to include the name of your specification e.g.

Code:
DoCmd.TransferText acImportDelim, "txtimport", "tblTemp", strFile, True
 
Unfortunately it will be users of the database who will select their csv file which could come from anywhere with any number of columns.

Solved it by creating a dummy Import Spec with 255 text fields and used that in the code.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom