Compacting a back end database from main switchboard

R

Richardson

I have a Fe/Be database setup running in Access Runtime developed in Office
XP Developer. At startup, the user chooses a backend file from a combo box
and is then dropped into the main switchboard. I would like a button on the
main switchboard that will run a compact on the backend file that they have
opened. From what I know, compacting that file while it is open would be
tricky, so I am looking for any suggestions or coding that you have.

Thanks in advance,
Lori
 
G

Graham Mandeno

Hi Lori

You have two options:

The first is to set the option in the backend to compact on close. You will
find this in Tools>Options>General.

If you want full manual control, then the procedure to compact from code is
to:
1) Ensure you have closed any forms/recordsets based on the backend.
2) Generate a temporary filename in the same folder as the backend
3) Use DBEngine.CompactDatabase <backend file>, <temp file> to do the
compacting.
4) Delete (or to be safer, rename) the backend file
5) Rename the temp file to be the new backend.
 

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