Assuming that the table exists then the following deletes it.
You should check for table first and, depending on what you are
doing you may want to ask user whether they want to delete it.
One, admittedly inelegant, way of checking a table exists is to make use of the hidden system file MSysObjects, thus:
Code:
If DCount("*", "MSysObjects","Name='Archive2' AND Type=1") = 1 Then
DBEngine(0)(0).Execute "DROP TABLE [Archive2];"
End If
Another way that doesn't depend on the tiresome DCount is just to turn error-handling off before the DROP TABLE so that it doesn't fall over when the non-existant table can't be deleted. Don't forget to turn it back on again afterwards...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.