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

Read from text file

Status
Not open for further replies.

drewduncan

Programmer
Apr 3, 2003
38
0
0
GB
Can anyone help:

I want to read data from a csv file which will be used to create records within a table - called Jobs.

The files can have various rows BUT each row always has 13 columns. Each column or data separated by a comma will be entered into a different field within the Job Table.

One row from the text file will contain information such as RefNo,CustomerName,HouseNumber,StreetName,Town,PostCode etc

RefNo will be copied into the RefNo field of the Jobs table, CustomerName will be copied into the CustomerName field of the Jobs table and so on.
Any help on how to do this would be greatly appreciated.

Cheers
 
See DoCmd.TransferText which will do just what you want.
 
OK think i understand what DoCmd.TransferText will do.

Is it possible however to state what field I want the data seperated by the commas to be transfered into?

e.g. The table that I am transfering the text file to has 32 fields. Only 13 of these fields will be given values from the text file?
 
You can use the specificationname argument to do this but it's not the easiest thing to set up and it's not very well explained. Try producing a specification and see it it solves the problem.

It may be simpler to allow DoCmd.TransferText to create a table containing all the fields and then write an update query to transfer the columns you are interested in to your table.
 
If you first manually import your file then you will be able to set up an import specification (press the advanced button on the Import Text Wizard), as part of this you may choose to skip fields you don't require (NB Make sure you click Save As when you're done, I've made the mistake of just clicking OK & losing an hours work!). You can then reference this with Docmd.TransferText.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top