DLookup Confusion

B

box2003

In the below code sample, Phase 1 works as it should.

Phase 2 causes errors and I am not sure why the errors are being caused. I
would appreciate another set of eyes on this. I have also been able to
create Phase 2 by using recordset method (not shown) and also generate the
same errors.

Thank you.

Msg1: The "Microsoft Access" type isn't an installed database type or
doesn't support the operation you chose.

Msg2: "Invalid file type"



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
 
G

Guest

I am not expert. However, just reviewing the help on the DLookup function I
notice a difference in synthax and wondered if this might not be your
problem? worth checking.

Help file synthax
varx = DLookup("[LastName]", "Employees", "[EmployeeID] = 1")

Your synthax
dbType2 = DLookup("dbtype", "dbconfig", "configid = 1")

You did not enclose field names in []. i would alter your code to include
the [] such as

'**** 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"

Also, use the immediate window to test the construction of your DLookup, use
debug.print statements or set break point in your code so you can validate
the returned values.
 

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