Question : Import a result set from DB2 to Access using TransferDatabase

I'm trying to create a table in Access with the results of a query against a DB2 server using TransferDatabase.  I've been able to successfully import a whole table, but get a "Jet database engine could not find the object 'Test'" error when I use a query.  Linking would not work, as I will be doing this for dozens of queries, but I need this done in Access, as we may be pulling back a few hundred thousand records for some of these queries.

Here's what I've been able to get working:
DoCmd.TransferDatabase acImport, "ODBC Database", "ODBC;DSN=XYZ;UID=XYZ;PWD=XYZ;", acTable, "TBL.TARGET_TABLE", "Test"

Here's what doesn't work:
DoCmd.TransferDatabase acImport, "ODBC Database", "ODBC;DSN=XYZ;UID=XYZ;PWD=XYZ;", acTable, "SELECT RECORD_KEY, RECORD_NO FROM TBL.TARGET_TABLE WHERE RECORD_KEY = 206", "Test"

I've tried it both with no "Test" table in the database, and a "Test" table with the two columns labeled as above.

Thanks for the help!

Answer : Import a result set from DB2 to Access using TransferDatabase

"Is it possible to programmatically create a pass-through query,"

If you create one passthrough query and save it, you can then modify the sql of that saved query to anything you like (that is valid for your database).
currentdb.querydefs("mypassthroughquery").sql = strSQL
You can then execute the passthrough query.

If you want to build an Append query then use the passthrough query as the source for your Access append query.


Random Solutions  
 
programming4us programming4us