delete mutiple objects at once

  • Thread starter Thread starter Dave
  • Start date Start date
D

Dave

Hi all,
Our '97 back end db has temp tables created in it, all
prefixed with the letters AA. Is there a way to delete
them all in one hit instead of manually deleting each?
There is another sequence of tables prefixed with ZZ, so
this procedure will save me time each time it needs to be
repeated.
Thanks in advance,
Dave
 
Quickest way will probably be to hold down the Shift key while deleting them
from the Database window. (This avoids the confirmation dialog.)

If you want to do it programmatically, you could loop backwards through the
TableDefs collection, deleting those with a matching Name.
 
Unfortunately, you will need to delete and confirm each and every deletion
access does not allow you to make multiple selections in the database
window. Otherwise you can do as Allen suggested and write some code to
delete the tables.

Regards,
Dan
 
Using DAO:

Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Select Name from
msysobjects where type = 1 and left(name,2)='aa'")
Dim rows() As String
Dim intCounter As Integer
ReDim rows(0)
Do Until rst.EOF
ReDim Preserve rows(UBound(rows) + 1)
rows(UBound(rows)) = rst("Name")
rst.MoveNext
Loop
For intCounter = 1 To UBound(rows)
DoCmd.DeleteObject acTable, rows(intCounter)
Next


There is no error handling, or object clean up in that
code, but it will work.


Chris Nebinger
 
Back
Top