csv Import into Access db

C

clk

I have a database set up that allows the user to click a button to
import a csv file for processing in the database. The process uses
"docmd.transferspreadsheet" code. This works just fine. The problem
is the company that sends them the csv file keeps changing it. Also,
they now have too many columns to be imported so they end up having to
delete columns out of the original csv file and then importing it. If
all the way a column has changed and they were not notified, it will
not import.

My question:

1. Is there anyway to import only certain columns of a csv file?
That way it shouldn't matter if they add a column or if there are too
many to import.

Any ideas are appreciated.

Thanks.
 
S

Stuart McCall

clk said:
I have a database set up that allows the user to click a button to
import a csv file for processing in the database. The process uses
"docmd.transferspreadsheet" code. This works just fine. The problem
is the company that sends them the csv file keeps changing it. Also,
they now have too many columns to be imported so they end up having to
delete columns out of the original csv file and then importing it. If
all the way a column has changed and they were not notified, it will
not import.

My question:

1. Is there anyway to import only certain columns of a csv file?
That way it shouldn't matter if they add a column or if there are too
many to import.

Any ideas are appreciated.

Thanks.

Well one way would be to import all the fields into a temp table, then use a
query to select only the fields you want so you can transfer them to your
main table.
 
K

Ken Snell

Using DoCmd.TransferText, you can speicify an import specification to
control the importation of a ".csv" file. The specification allows you to
designate columns as ones to be "skipped".

You create an import specification by manually beginning the import process
(via File | Export). When you're in the wizard window, click the Advanced
button at bottom left. In the new window, you'll see all the settings you
can specify. Enter all the information. Click Save As button and save them
as a specification (name it whatever you want, e.g., "MyEImportSpec", for
example). Click OK button to return to the main window of the wizard. Then
click Cancel button to cancel the rest of the import.

Now go to your TransferText code and add the name of the specification to
the appopriate argument position.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top