Using ADO to import CSV into Access

RichardMGreen

Well-known Member
Joined
Feb 20, 2006
Messages
2,177
Hi all

I've got the following line of code that's throwing out an error.
conn.DoCmd.Transfertext acImportDelim, , loadtable, keepname, True

I've set up conn as the ADO connection to the database and it's supposed to import a CSV into loadtable using the file keepname.

I'm using Option Explicit to ensure all variables are pre-designed but the acImportDelim is throwing an error as not defined.

Two questions:-
1) Am I doing this correctly?
2) If so, what should acImportDelim be defined as?
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Are you running this code in Excel?

If so, it won't have a value for acImportDelim unless you have the correct reverences.

replace it with 0 or define acExportDelim as a constant with the value of 0 elsewhere in your code.
 
Upvote 0
DoCmd and acImportDelim belong to Access not ADO. You would have to create an Access.Application object to use that.
 
Upvote 0

Forum statistics

Threads
1,224,574
Messages
6,179,626
Members
452,933
Latest member
patv

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top