TransferText not working

G

Guest

Acess XP, Windows XP

I have an import specification to import an 85 character per line text file.
When I run the import specification thru the import wizard the table
populates correctly, when I use the code below it only imports the first two
columns. Is this because there are too many characters per line in the text
file, if so is there another way to automatically import this text file.

Dim strfile As String

ChDir ("C:\Documents and Settings\My Documents\")
strfile = Dir("Download.txt")
Do While Len(strfile) > 0
DoCmd.TransferText acImportDelim, "Download Import Specification",
"Download", "C:\Documents and Settings\My Documents\" & strfile, True
strfile = Dir
Loop
 
J

John Nurick

Hi,

An "85 character per line text file" implies that it's a fixed-width
file, not a delimited one. If so, you should use acImportFixed rather
than acImportDelim.

Also, the loop in your code isn't necessary. You can use something like
this:

Dim strFile As String

strFile = "C:\Documents and Settings\My Documents\Download.txt"

'Check whether file exists
If Len(Dir(strFile)) > 0 Then
DoCmd.TransferText acImportFixed, _
"Download Import Specification", _
"Download", strFile, True
Else
MsgBox "File " & strFile & " not found."
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top