Hi,
I'm trying to do a DLookup to get values in a table. The table is not in my current database, it is in a common-code database called "AccessCommonCode.accdb".
This database contains utility code that I use from various "main" databases, by adding a reference in each database to "AccessCommonCode.accdb").
This works very well. Some VBA commands that normally use CurrentDB require change to CodeDB.
For example, if a table resides in the "main" db, I would use:
Code:
CurrentDB.Execute "Delete * From MyTable"
But if the table resides in the referenced common code db, I need to use:
Code:
CodeDB.Execute "Delete * From MyTable"
Changing DB name from CurrentDB to CodeDB causes code being executed in the referenced DB to work properly.
Now I need to do a DLookup on a table which resides in the referenced DB.
This DLookup is being executed in the "main" DB.
Code:
MyName = DLookup("MyName","MyTable", "ID = 25"
This causes an error because it can't find "MyTable" in the "main" db.
"MyTable" indeed exists in the referenced DB, but not in my "main" DB.
Is there a way to modify the domain part of the DLookup so it points to the table in the referenced DB?