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 from ODBC in macro or VBA

Status
Not open for further replies.

heathlovell

IS-IT--Management
Oct 26, 2002
36
US
Hello,
I would like to write a macro or VBA module to import a table from an ODBC source. Can anyone help me with this?
Thanks,
Heath Lovell
 
Hello Heath,
Here is the code that you require. Simply place it in a VBA module:
Code:
DoCmd.TransferDatabase acImport, "Microsoft Access", "[c:\myfolder\db1.mdb]", acTable, "[Table1]", "[Table1]"

Or for ODBC databases:
Code:
DoCmd.TransferDatabase acImport, "ODBC Database", "ODBC;DSN=[MyDataSource];UID=[UserName];PWD=[Password];LANGUAGE=us_english;DATABASE=[MyODBCDatabase]", acTable, "[Table1]", "[Table1]"

Simply replace the text in the square brackets [], and be sure to discard the square brackets as well.

Good Luck,
Robert Professional, affordable, Access database solutions and assistance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top