DCount("Name", "MSysObjects", "Name = " & [tableName] & " AND Type = 1")
The MSysObjects is the table which contains information on all objects
within an Access database. The Type Field indicates the type of object 1
= Table.
The methods posted will both work well; however, a faster approach would be
to turn error handling off, do the delete, then turn error handling back on.
That way, you don't have to take up cycles looking for it:
On Error Resume Next
DoCmd.DeleteObject acTable, "MyTableNameHere"
Actually, it's very rare to need to delete a table. What about just
emptying it -- which will reduce the mbd file bloat, be much quicker and,
at a guess, reduce the chance of file corruption.
db.Execute "DELETE FROM MyTable;", dbFailOnError
If err.Number <> 0 Then
' oops, the table wasn't there after all
db.Execute "CREATE TABLE MyTable (..."
Hope that helps
Tim F
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.