What is the difference between DoCmd.DeleteObject acTable Vs. CRUSHING TABLE

Details:

I have an MS-Access Database procedure where I locally create tables in a database. However, I want to make sure that the tables that I create are checked, and if the test fails, I need to delete / delete other created tables. Basically, the rollback procedure, I think.

Question:

I came across two methods for deleting tables, but I canโ€™t figure out if it has more about than minus, etc.

Can someone tell me what is the difference?

Thank you very much!

+4
source share
2 answers
DoCmd.DeleteObject acTable, "aaaTest" 

... and ...

 Dim cdb As DAO.Database Set cdb = CurrentDb cdb.Execute "DROP TABLE [aaaTest]", dbFailOnError 

... and ...

 Dim cdb As DAO.Database Set cdb = CurrentDb cdb.TableDefs.Delete "aaaTest" 

... all these are different ways to solve the same problem. They delete the local TableDef object with this name (either the actual local table or the table reference).

+10
source

I just found out that DropTable doesn't like table names with dashes in them. I had a lot, so I used DoCmd.Rename to rename the table right before I used droptable to erase them. It was the easiest solution for me, because I had 15 tables with dashes in them and 60 all together, which I delete on exit to clear temporary files.

0
source

All Articles