Programmatically tell if table oject exists.

  • Thread starter Thread starter Steven
  • Start date Start date
S

Steven

When I am in a access database program I want to delete a
table in the database if it exists but I
want to ask first if the table exists so it will not error
from trying to delete a nonexisting object.

How do I ask if the table object exists first.

Thank you for your help.

Steven
..
 
If Not IsNull(DLookup("ID", "MSysObjects", _
"Type = 1 AND Name = 'MyTable'")) Then

If you are creating and deleting the same table constantly, you may find it
easier to:
dbEngine(0)(0).Execute "DELETE FROM MyTable;", dbFailOnError
 
Back
Top