Batch delete tables

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hey,

Does anyone have a suggestion on how the batch delete tables based on when
the tables were created (date and time), my database is consistently filling
up with tables to the point where my database is >1GB. I am definitely a
novice at code writing, so any help would be greatly appreciated.
 
Just to clarify, I would to specifiy between two dates and time. If I can
only do after I date and time, that would be great to. Thanks a lot in
advance.
 
Kevin said:
Just to clarify, I would to specifiy between two dates and time. If I
can only do after I date and time, that would be great to. Thanks a
lot in advance.

What exactly is creating tables and why would you no longer need them? The
constant creation and deletion of tables is certainly not a "normal" thing
to be doing.
 
I am using Access as a temporary archiving tool for multiple tables being
produced by statistical models. Each time the model is run, 10 different
large tables are produced. Analyses are run based on thetables within Access,
they are temporarily archived, then not needed at the end of the day.
 
Step #1

create this table as tblObjectsDescribed

tblObjectsDescribed type describe
-32768 form
-32766 macro
-32764 report
-32761 module
1 table
5 query
8 relationships



step #2

Create this query: SELECT tblObjectsDescribed.describe,
MSysObjects.Connect, MSysObjects.DateCreate, MSysObjects.DateUpdate,
MSysObjects.Name, MSysObjects.Database
FROM MSysObjects LEFT JOIN tblObjectsDescribed ON MSysObjects.Type =
tblObjectsDescribed.type
ORDER BY tblObjectsDescribed.describe DESC;

When the query is run, you will see the dates of the tables. Be sure to
avoid doing anything with the Msys.. tables!

That information, after manipulation, can then be used to delete the tables
or, perhaps, rename them so that code like this can delete them (this is not
my code ..I picked it up somewhere):

Access's MSysObjects system table contains information about all the tables
in a database. You can use this information to delete tables or queries that
meet specific criteria-and you don't need to unhide the system table to do
so. For instance, you can use the code shown below to delete all tables with
a name that begins with a "TEMP_" tag. If you want to change the code to
delete queries, simply set [Type] equal to 5 and change the acTable constant
to acQuery.

Public Function DelTable()
On Error GoTo DelTable_Err
Do While DCount("[Name]", "MSysObjects", _
"[Type]=1 And [Name] Like ""TEMP_*""") > 0
DoCmd.DeleteObject acTable, DFirst("[Name]", _
"MSysObjects", "[Type]=1 And [Name]
Like ""TEMP_*""")
Loop
DelTable_Exit:
Exit Function
DelTable_Err:
MsgBox Error$
Resume DelTable_Exit
End Function


Bob
 
Kevin said:
I am using Access as a temporary archiving tool for multiple tables
being produced by statistical models. Each time the model is run, 10
different large tables are produced. Analyses are run based on
thetables within Access, they are temporarily archived, then not
needed at the end of the day.

A good solution then is to build the temporary tables in a separate file and
link to them. Then when you are finished with them the separate file is deleted
entirely. Your base file then does not suffer the bloat of having all of those
objects created and then deleted.
 
Back
Top