Variables in TransferDatabase Method for DatabaseType and Database

B

box2003

In the below code sample for Phase 2, I am attempting to replace the dbType2
and dbPath2 variables with the results from a dbConfig table using the
Dlookup function. Phase 2 causes errors and I am not sure why the errors are
being caused. Phase 1 does work as it should. Validation of the Phase 2
variables for dbPath2 and dbType2 contain the correct double quoted
information for the TransferDatabase method however, the function throws an
error. Please offer some insight how I can incorporate the variables into
the TransferDatabase

Error: "Invalid File Type" or "Microsoft Access is not an installed database
or does not support the operation you chose"

Thank you.


Private Sub Command0_Click()

Dim dbPath1 As String
Dim dbType1 As String

Dim dbPath2 As String
Dim dbType2 As String

'**** PHASE 1 ****
MsgBox "entering phase 1"

dbPath1 = "C:\Documents and Settings\Dev\devRollback.mdb"
dbType1 = "Microsoft Access"
DoCmd.TransferDatabase acExport, dbType1, dbPath1, acTable, "State",
"State_bkp"

MsgBox "exiting phase 1"

'**** PHASE 2 ****
MsgBox "entering phase 2"

'in table dbconfig, dbtype = "Microsoft Access", with quotes
'in table dbconfig, dbpath = "C:\Documents and
Settings\Dev\devRollback.mdb", with quotes
dbPath2 = DLookup("rollbackpath", "dbconfig", "configid = 1")
dbType2 = DLookup("dbtype", "dbconfig", "configid = 1")
DoCmd.TransferDatabase acExport, dbType2, dbPath2, acTable, "State",
"State_bkp"

MsgBox "exiting phase 2"

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top