docmd.transfertext opens csv with improper format (1 Viewer)

Zach Lau

Registered User.
Local time
Yesterday, 18:54
Joined
Mar 6, 2013
Messages
11
I have a now somewhat large app that depends on this line of code. I am using DoCmd.TransferText to import a csv file into a temp table. The entire program depends on the data being imported from the csv file entirely in text format. About 90% of my csv files do import entirely in text. I however have a batch of files ("The program scans a directory") that have data formats that are automatically converted to numeric formats.



filenameformatted is a variable that represents a table. Temporary_Imports is the table that it is being imported to.

DoCmd.TransferText acImportsDelim, , "Temporary_Imports", filenameformatted

I tried saving a specification called Format1 that specifies that all fields are imported as text. This caused the files to not even be imported. This is the last bug I believe that I have to work out of this application. Can anyone help me to import a csv file, ensuring that all fields are imported as text?

This is an entirely automated application, so I am not looking for a solution such as open the file in excel... or anything outside of Access vba. Help please.
 

boblarson

Smeghead
Local time
Yesterday, 16:54
Joined
Jan 12, 2001
Messages
32,059
Zach

You need to use the import spec or Access will just guess based on the first few rows. But with the newer versions of Access, you can't use the name you gave the import spec. You have to use its Index number from the MsysImEx table.

To figure out what number it is, you have to set your navigation pane to display system tables.
 

Zach Lau

Registered User.
Local time
Yesterday, 18:54
Joined
Mar 6, 2013
Messages
11
Thank you so much. I can do this.
 

boblarson

Smeghead
Local time
Yesterday, 16:54
Joined
Jan 12, 2001
Messages
32,059
Zach:

It appears I was incorrect with this. I got it to work in 2010 with the spec name. But it has to be in quotes. Did you try that?
 

Users who are viewing this thread

Top Bottom