Delete Table

M

M.A.Halim

Dear Group
I have a data base with some tables that I don't need any more, no longer in
use and these tables just increasing the size of my database at the same time
i don't want to use a delete query to get rid of these tables I used the
following command but didn't work, but it actaully worked perfect with
queries and reports? any Idea how can I use the right command?

DoCmd.DeleteObject acTable, "Customers Tbl"

Thanks A lot
 
K

Klatuu

Why not just open the database in design mode, select the Tables tab, select
the table you want delete, and press the Delete key?
The code you posted should work in the VBA immediate window.
 
M

M.A.Halim

Thanks for reply Dave
There is date and some other conditions that must be met first then the
table will be usless and then should be deleted, I don't know when these
conditions will be met that's why I don't want to open the databse window and
do it manually.
So if my code didn't work what is the command to be used in order to run a
delete query for that "Customers" table lets say the the query name is
"DelCustomersQry"
DoCmd.Runquery....or DoCmd Requery,...........etc.
Thanks again
 
M

M.A.Halim

I Discovered why that code didn't work... that's because the table has some
relationships with other tables. so most properly I need to use a delete
query can you show me the command to use to run this delete query??? Thanks a
lot
 
K

Klatuu

Use a command button, but if there are relationships to the table, then you
may be leaving orphan records in the other tables.
 
J

John W. Vinson

I Discovered why that code didn't work... that's because the table has some
relationships with other tables. so most properly I need to use a delete
query can you show me the command to use to run this delete query??? Thanks a
lot

Deleting the records will not delete the relationship. Your best bet would be
to open the Relationships window; view the relationships to this table; click
the relationship line joining the two table icons and press the delete key to
delete the relationship.

Then select the table in the Tables window and delete it.

It makes NO difference *how* you delete the table, in code, in the query grid,
or whatever - if there are reasons the table cannot yet be deleted, *don't
delete it until those conditions are met*.

Compact and Repair the database after you succeed in deleteing it, to recover
the space it occupied.
 

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