import specific csv columns to specific fields in table

shaunh1

New member
Local time
Today, 17:56
Joined
Jul 6, 2010
Messages
1
Hi,
I am trying to write a VB script that would copy rows of a csv file and append an existing table with new entries. But I only want to copy a subset of columns of the csv file to a subset of table fields.

E.g. the csv file contains a few columns, but I am only interested in importing data from three columns titled (in the first row) "Date", "Amount", "Transaction Narration" to an existing access table called "tblTrans" with field names BankDate, Credit, BankDescription. tblTrans also contains other (required) fields, which will be filled out by the user in a form after the csv import is complete.

Any ideas of how I can do this in a VBA script?
 
Why not use a simple DoCmd.Transfertext ??

This does import all columns, but you import first into a temp table, then use an append query to only appen the data from the columns you want to the 'real' target table.

This will both be much faster and much easier to maintain
 

Users who are viewing this thread

Back
Top Bottom