Checking if a table exists in VBA

M

Minnie

I have created some Make-Table Queries to hold sales data on a monthly basis.
I have added a command button to a form to allow the user to refresh the data
as needed. The command button runs five different make-table queries. I was
able to find out how to get rid of the notification dialog boxes, leaving
only the confirm deletion dialogs (five in all). To get past this I added the
delete command to the command button (Docmd.Delete Object acTable,
stTableName) and that works fine. Only problem is I can't find out how to do
a check that that object exists. If I run the code after manually deleting
the first table the system displays a message that the table does not exist
and then stops the whole operation.Is there an "If Exists" property I can use?

Thanks for any help you can offer.
 
P

Paul Overway

Handle the error, i.e.,

On Error Resume Next
Docmd.DeleteObject acTable,"TableName"
 
G

Graham R Seach

Minnie,

I'm more inclined to ask why you need to constantly create and then delete
tables. Im supposing the structure of each table is the same each time it is
created, in which case, you'd be better served by creating each table once,
then just deleting its data (if the data is temporary).

Creating objects in Access tends to bloat the database file.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
Top