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

Macro to import ODBC table

Status
Not open for further replies.

xsnrg

Technical User
Jun 15, 2004
44
US
I am trying to write a macro that will import a table or series of tables from an ODBC SQL database.

I'm using the "TransferDatabase" option in the macro with this argument in the 'DatabaseName' property...
Driver={SQL Server};database=dbName;Server=srvName;UID=User;password=Password;

I'm getting an error. I know the data is there since I can MANUALLY import the table, but I cannot get the macro to automate it.

Doing this in a Module VBA options would be fine too. Any help?

 
This is how you would import a SQL Server table using VBA.

Code:
Public Function ImportFromSQL()

    DoCmd.TransferDatabase acImport, "ODBC Database", _
        "ODBC;DSN=DataSource1;UID=User2;PWD=[URL unfurl="true"]www;LANGUAGE=us_english;"[/URL] _
        & "DATABASE=pubs", acTable, "Authors", "dboAuthors"


End Function

ProDev, MS Access Applications
Visit me at ==> Contact me at ==>lonniejohnson@prodev.us

May God bless you beyond your imagination!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top