Is there a code that deletes all forms,queries or tables?

D

Dale Fye

Take a look at the docmd.DeleteObject method.

You can put this inside a loop, something like:

For each tbl in currentdb.tabledefs
docmd.deleteobject acTable, tbl.name
next


--
HTH
Dale

email address is invalid
Please reply to newsgroup only.
 
D

Dirk Goldgar

Dale Fye said:
Take a look at the docmd.DeleteObject method.

You can put this inside a loop, something like:

For each tbl in currentdb.tabledefs
docmd.deleteobject acTable, tbl.name
next


Watch out, Dale! If you did that without any further qualification, you'd
end up deleting some system tables. You need to exclude tables whose names
begin with "MSys".
 
J

John Spencer

Also, you would probably delete every other table/object.

Delete table #0
Table #1 moves to position #0
Advance to next table position
Table #2 is now in position 1
Delete table #2
Table #3 is now in position 1
Advance to position 2
Delete Table #4 which is in position 2

etc.



John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 
D

Dirk Goldgar

John Spencer said:
Also, you would probably delete every other table/object.

Delete table #0
Table #1 moves to position #0
Advance to next table position
Table #2 is now in position 1
Delete table #2
Table #3 is now in position 1
Advance to position 2
Delete Table #4 which is in position 2

etc.

There's some question in my mind whether using the DeleteObject, as Dale was
proposing, would have that effect or not, since he's looping through the
TableDefs collection but not using the collection's Delete method. I didn't
take the time to test it.
 
D

Dale Fye

Good catch, Dirk.

I was waiting for a co-worker to go to a meeting, and shot from the hip.
Probably not the best course of action for something as critical as this.

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.
 
J

John W. Vinson

Hi,

Is there a code that deletes all forms,queries or tables?

First off:

WHY would you ever want to do this!?

If you're creating a new database, create a new database, and Import those
objects that you want to keep.
 

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