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!

Import CSV file to a table in Access using VBA

Status
Not open for further replies.

ravensks

Technical User
Nov 7, 2003
2
US
I have a CSV file that updates once per day, it contains 15 fields however I want to execute code that imports only the first 6 fields into a table in an Access DB. Preferably, I am trying to set up a form with a cmd button that executes this all in one action. The CSV does contain headers and should copy the headers if they do not already exist.

If anyone could get me started off with some code help It would be greatly appreciated. Thanks!
 
You can use DoCmd.TransferText with an import specification, which will allow you to assign the fields to be imported:
[tt]DoCmd.TransferText acImportDelim, "[blue]A Import Specification[/blue]", "NewTable", "A.csv", True[/tt]

If you are importing a file to an existing table, the data will be appended, if you import to a new table, you can set the argument for field names to 'true' to create field names.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top