Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TransferText imports whole line in first field of import table

Status
Not open for further replies.

MickelR

Technical User
Mar 10, 2010
21
0
0
NL
Hi,

I have a txt file. Each line in this file has the same width for each record (fixed width). I have created an import spec by importing the file for the first time, putting the break lines at the correct positions and then save the spec in the import table. So far, so good.

I have created a form with a button that should start the import, using DoCmd.TransferText.
Code:
DoCmd.TransferText acImportDelim, "MT535Spec", "tblDownloadExtern", strBestand, False
The MT535Spec is the saved import specification (spelling has been double checked and is correct) for fixed width of each line.

The challenge: when manually import the same file using the saved import specification, the file is imported perfectly. Using the TransferText option MS Access tries to store the whole line of the text file in the first field of the table, instead of dividing the line into seperate fields.

Microsoft MSDN writes about "fixed width" files: SpecificationName - Optional Variant. A string expression that's the name of an import or export specification you've created and saved in the current database. For a fixed-width text file, you must either specify an argument or use a schema.ini file, which must be stored in the same folder as the imported, linked, or exported text file.

In my opinion I am supplying an argument, which would be "MT535Speci". Any ideas what I could be overlooking here?



--------
For Google indexing purpose: MS Access VBA importing txt file manually works fine, but using TransferText results in the whole line stored in the first field of a record.
 
Okay... I did find the problem. Use acImportFixed rather than acImportDelim!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top