Checking if a table exists in VBA

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
Handle the error, i.e.,

On Error Resume Next
Docmd.DeleteObject acTable,"TableName"
 
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
 

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

Similar Threads


Back
Top