Deleting a table in another database

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
 
D

Dirk Goldgar

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
 

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

Top