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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Importing text-file into Access97 database

Status
Not open for further replies.

hniessen

Technical User
Jan 31, 2002
12
NL
As a not-so-experienced Access user I ran into an interesting problem. Namely, I want to search for data in a txt-file, which is generated by another tool. This txt-file contains 25 columns each separated by a comma. When the second column contains a value that satisfies a certain condition the row has to be added to a table. Which I want to do using VBA or a macro.

Greatings,
Hans Niessen
 
I would import the entire txt file into a temporary holding table in your database, then run an append query to add the appropiate rows to your main table.

Assuming of course that the text file doesn't contain 1000's of rows and you only need 2 of them. If that's the case then maybe you need to look at possibly creating a different text file that meets your needs better. Maq B-)
<insert witty signature here>
 
Okay, that i thought of as one of the possible solutions. But how do i import the text file into the database. I can't figger it out using help. Most of the tutorials i use are in english but the version of access i use is german and i am dutch. Very confusing all together.

Greatings,
Hans
 
Well, I don't know German or Dutch, only English.

You import by using the File ---> import menu or if you are using a macro or VBA code use the docmd.transfertext command.

For your file I think the syntax would be:
DoCmd.TransferText acImportDelim, , &quot;tabletoimportto&quot;, filepath&name, True

That last argument indicates whether or not the file has a header row. True = headers, False = no headers.

Hope that helps some.
Maq B-)
<insert witty signature here>
 
I have a very complicated piece of code for data from a text file which is comma seperated but because it contains upto 30 different record types with different numbers and types of data won't import directly into Access. If the standard import methods fail I'll post up the general method. The actual code is about 30 pages of A4.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top