Importing Txt File (1 Viewer)

Number11

Member
Local time
Today, 13:08
Joined
Jan 29, 2020
Messages
607
I am trying to import a txt file into a table using this..

DoCmd.TransferText acImportDelim, , "Importing_Table", strFileName, False

getting error runtime 2391

Field "F1" doesn't exist in the destination table Importing_Table
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 08:08
Joined
Feb 19, 2002
Messages
43,293
The message is telling you the error. The file has a column named "F1" but you have not accounted for it in your target table. This is probably an error but you either have to figure out how to get rid of it or add it to your target table.
 

Number11

Member
Local time
Today, 13:08
Joined
Jan 29, 2020
Messages
607
The message is telling you the error. The file has a column named "F1" but you have not accounted for it in your target table. This is probably an error but you either have to figure out how to get rid of it or add it to your target table.
no sory the txt files doesnt have any headers at all its raw data
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 08:08
Joined
Feb 19, 2002
Messages
43,293
Then please post your db with the table and the text file.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:08
Joined
May 7, 2009
Messages
19,245
you need VBA to import it.
either reading line by line or
reading the whole text and splitting it then importing it.
 

Number11

Member
Local time
Today, 13:08
Joined
Jan 29, 2020
Messages
607
you need VBA to import it.
either reading line by line or
reading the whole text and splitting it then importing it.
yes i am trying to do this via VBA is i add headers to the file it imports but if i remove the headers it fails the data is shared without headers so how can i import the files with no headers?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:08
Joined
May 7, 2009
Messages
19,245
as suggested you show us a partial content of the textfile.
then we can work to create a function/sub for you.
 

Number11

Member
Local time
Today, 13:08
Joined
Jan 29, 2020
Messages
607
as suggested you show us a partial content of the textfile.
then we can work to create a function/sub for you.
1660746405854.png
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:08
Joined
May 7, 2009
Messages
19,245
how does it look in notepad. i need to see the delimiters.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:08
Joined
May 7, 2009
Messages
19,245
here is a demo db.
 

Attachments

  • ProcessTextfile.accdb
    448 KB · Views: 127

Pat Hartman

Super Moderator
Staff member
Local time
Today, 08:08
Joined
Feb 19, 2002
Messages
43,293
I guess you don't care about finding out what is wrong with the file.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 13:08
Joined
Sep 12, 2006
Messages
15,658
Normally a CSV is comma separated, and a text file is fixed column width, and you use a file import specification file. Depending on how many columns there are, you can get this problem, but you normally get this with columns at the end of the file, sort of F13, F14.

Maybe you are accidentally importing as fixed width, rather than CSV. Something like that, and your whole text is being treated as a single column.
 

Users who are viewing this thread

Top Bottom