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

Importing ODBC Data

Status
Not open for further replies.

plawrence

Technical User
Dec 9, 2002
14
0
0
US
I have a routine that imports ODBC data using:

DoCmd.TransferDatabase acImport, "ODBC Database", !ConnectString, acTable, !SourceTable, !LocalTableName, False

The problem is sometimes I need to manually select File>Get External Data>Import, select ODBC from "Files of Type", select the Data Source, then hit "cancel" when the "Import Object" box pops up, THEN I can run the routine. I have to do this for each database I'm importing from or I'll get an ODBC error. It's like I have to go through all the motions manually without actually importing anything before my routine will do it.

Any ideas of what's happening?

Patrick
 
You need to specify all the connection parameters for the database such as password, server etc. If any needed parameter is missing, Access can't figure out how to make the connection and it prompts you for the info.
 
That's what I don't understand. There is no password and everything is set up correctly in the user DSN. What's bothering me is why do I have to step through the process manually before the code will work. I always get the same error: 3151 ODBC--connection to <my db> failed. When I go back and do it manually, the connection is fine.

Is there a way to check the connection first or open a connection with VBA?

Patrick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top