Programmatically tell if table oject exists.

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
..
 
A

Allen Browne

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
 

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