How would I be able to check whether or not a given table (called Items
) is in a specific Access database through Excel vba.
I have built connections from the excel sheet to two different databases, [A] & [B], through Excel vba and my other code is working fine.
So far, the closest I have been able to find online is:
If IsNull(DLookup("[Name]", "MSysObjects", "[Name]='Items'")) Then
This code doesn't specify which database I would like to search. Is there a way I could write a statement to run only if table Items
is not found in Database [B]? How would this code be written?
I have no problem referencing the database. Most of my code is SQL that is being run from Excel, and I'm able to referenece various entries in fields specific to each database. I'm just looking for a line that says "If this table doesn't exist in this database, then create a table with that name". Is there maybe an SQL string I could write, or even a try...catch method?
Any help would be greatly appreciated