Can you disable Compact on Close in code?

P

Paul

I have an mdb application set to 'Compact on Close' in the Tools - Options
dialog. I'm also using 'DoCmd.Quit acQuitSaveNone' to close the application
upon certain events. There are times, however, when I don't want the file
to compact and repair itself when it closes, but rather just close down
without compacting.

Is there a way to turn off the 'Compact and Repair' setting in VBA code?

Thanks in advance,

Paul
 
G

Graham Mandeno

Hi Paul

Call SetOption("Auto Compact",False) will turn the option off.

It will not revert to its old state automatically the next time the database
is opened, so if you want it turned on by default then add
Call SetOption("Auto Compact",True)
to your startup code.
 
P

Paul

Great!

Thanks, much, Graham. And thanks for the tip about turning it back on.

Paul


Graham Mandeno said:
Hi Paul

Call SetOption("Auto Compact",False) will turn the option off.

It will not revert to its old state automatically the next time the
database is opened, so if you want it turned on by default then add
Call SetOption("Auto Compact",True)
to your startup code.

--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

Paul said:
I have an mdb application set to 'Compact on Close' in the Tools - Options
dialog. I'm also using 'DoCmd.Quit acQuitSaveNone' to close the
application upon certain events. There are times, however, when I don't
want the file to compact and repair itself when it closes, but rather just
close down without compacting.

Is there a way to turn off the 'Compact and Repair' setting in VBA code?

Thanks in advance,

Paul
 

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