Compacting a database (Access 97)

  • Thread starter Thread starter Phil Hood
  • Start date Start date
P

Phil Hood

Hi,

I see that it is possible to compact an open database
using:

Tools -> Database Utilities -> Compact Database

I want to incorporate this into an event procedure but
I'm not sure how to code it.

Nb. I don't want to create a new version of the database
which seems to be a pre-requisite of the CompactDatabase
method.

Any ideas greatly appreciated.

Thanks Phil.
 
You really should create a new version, even if only to delete it once you
know that compaction was successful. What I typically do is rename the
database by changing the extension from .mdb to .bak, then compact the .bak
file to the "correct" name. (Depending on my application, I often
incorporate a date in the renamed file as well as the extension change).
That way, I get a "free" backup.

But if you're asking can you compact the open database from within itself in
code in Access 97, the answer is no. Take a look at the free TSI SOON (Shut
One, Open New) add-in MichKa has at
http://www.trigeminal.com/utility.asp?ItemID=8#8
 
Hi,

Thanks once again for your help. I've managed to get this
to work but I wonder if you can help some more as I'm not
sure where to position the code? At present, I've only
got it to work by creating a new database and setting up
the code to compact a closed database.

What I want to do is to compact the database each time I
exit. So I want to create an event procedure that does
just this. However, you say that you cannot compact an
open database but once it is closed, the event procedure
will not execute.

So, where should I put the code to make it work?

Thanks again in anticipation.

Phil.
 
The scenario I was describing was for a split application: a front-end
(containing the queries, forms, reports, macros and modules) linked to a
back-end (containing the tables). I compact the back-end from the front-end.
If your application isn't split, then you have no choice but to look into
MichKa's add-in that I mentioned in my previous answer. It comes with
documentation on how to use it.
 
Back
Top