Compact Repair code?

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

Guest

Hi guys,

Can anyone give me code or point me to a site that has code that will
programmatically compact and repair my DB when a user clicks a button on a
form.

The difference to all the other Compact/Repair questions is i don't want to
C/R the open FE App but my BE DB residing on a shared server.

If you can also show me how to schedule it at night that would be even better.
 
Check Access Help on the Startup Command-line Options. There is an option
to compact a database.

You can use the OS Scheduled Task to start MsAccess with the Compact option
to compact the database file.
 
There is a very easy solution for this. Set the be to Compact on Close. It
does not actually close until the last user closes his fe. That means that
at least one every evening, the be will be compacted and repaired. I have
been using this method for about 6 years. I also have an autoexec macro in
the be with one line:
Docmd.Quit

It serves two purposes. 1, keeps idle lookers out of the be, 2, closes it
after the compact/repair

Even if you did it from code in the fe, the user doing it would need to have
it open exclusive to keep from blowing other users out of the water.
 
So opening the be from the fe *doesn't* trigger the AutoExec macro but *will*
trigger the Compact on Close? Cool! I didn't know that. That's going to come
in handy for this application I'm building right now.

Thanks,
RD
 
Exactly, it is really handy. As I said, I first learned that trick in either
1999 or 2000.
 
Back
Top