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

Import ODBC table into a different database (not into the current one)

Status
Not open for further replies.

LegalizeTheTruth

Programmer
Jan 20, 2011
4
DE
Hello! It might be an easy question for you, but I don't find an answer to it. I have the following code, which works perfectly:
Code:
DoCmd.TransferDatabase _
    TransferType:=acImport, _
    DatabaseType:="ODBC Database", _
    DatabaseName:=init.dbLogin, _
    ObjectType:=acTable, _
    Source:=init.dbTable, _
    Destination:=init.useTableName
Those variables in the init module are public and defined like this:

dbLogin = "ODBC;DSN=CEPC;UID=MYID;PWD=MYPASS;LANGUAGE=us_english;DATABASE=CEPC"
dbTable = "tbl_prod_mas"

Now that init.useTableName is a name I can give in a form's input text field, representing the name of the target table.

So my question: Is it possible to include a different Database in the Destination parameter? Like this:
Destination:=[Different/Database/Path/TargetDB.accdb].[TargetTable]
...so I don't have to import from ODBC to the current db but to different one.

I could use different approches to this problem, like linking the ODBC table and set a variable for the target DB, then use a sql query like targetDB.Execute "SELECT * INTO TargetTable FROM tbl_linkedODBC", but I'm curious whether it's possible or not.

Thanks people... any help is appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top