TransferText not working

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
Back
Top