Compact Repair code?

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.
 
V

Van T. Dinh

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.
 
G

Guest

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.
 
R

RD

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
 
G

Guest

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

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

Similar Threads

Compact & Repair 1
Compact and Repair in Access 07 1
Compact and Repair database 2
Compact Database 2
Compact and Repair 3
Compact Repair 2003 in VISTA 3
compact database in VBA access 2007 5
Compact and Repair 2

Top