Compact and Repair Macro

R

rml

Does anyone know if or how to create a macro to compact and repair? If not,
how can compact and repair be done automatically at a scheduled time?

Thanks.
 
T

Tom van Stiphout

On Fri, 25 Apr 2008 06:14:00 -0700, rml

Your second option is better. Simply schedule a task to run and
execute:
<path_to>msaccess.exe <path_to>your.mdb /repair /compact

-Tom.
 
J

Jim Ory

I don't use a macro, but this might work for you:
Create a command button on a form. I use the Main Switchboard in one
database and a Add/Edit form in another. Using the On Click event of the
command button:

Private Sub Command172_Click()
On Error GoTo ProcError
CommandBars("Menu Bar"). _
Controls("Tools"). _
Controls("Database utilities"). _
Controls("Compact and repair database..."). _
accDoDefaultAction
ExitProc:
Exit Sub
ProcError:
MsgBox "error" & Err.Number & ": " & Err.Description
Resume ExitProc
End Sub

This usually works fine, but because there is one form open, the database
does not compact as much as when the form is closed. Not a lot of difference,
though.
 

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