Deleting a table in another database

  • Thread starter Thread starter Miguel Velez
  • Start date Start date
M

Miguel Velez

I've written an application that opens another Ms Access
database, creates a new table in that database, copies all
the records from an existing table into the new one. then
want to delete the original table. The "DoCmd.DeleteObject
acTable tablename" statement looks for the table in the
current database and it's not there and it crashes.

Does anyone know how can effect this delete?

Michael
 
Miguel Velez said:
I've written an application that opens another Ms Access
database, creates a new table in that database, copies all
the records from an existing table into the new one. then
want to delete the original table. The "DoCmd.DeleteObject
acTable tablename" statement looks for the table in the
current database and it's not there and it crashes.

Does anyone know how can effect this delete?

I assume you have a database variable set to the the other database you
opened. Suppose that variable is called dbOther. Then you might delete
table "OldTable" using code like this:

dbOther.TableDefs.Delete "OldTable"

Or you could execute a DROP TABLE query in the other database:

dbOther.Execute "DROP TABLE OldTable", dbFailOnError
 
Back
Top