Automated Compact and Repair

LB79

Registered User.
Local time
Today, 16:41
Joined
Oct 26, 2007
Messages
505
Hello,

I want to add a code to run when a database is closed that performs the Compact and Repair function.

I found the code listed below, but I having trouble making it work.
Also, if I can get this code working, does anyone know if I can prevent the database from reopening after this function?

Thanks
Public Sub CompactDB()
CommandBars("Menu Bar").Controls("Tools").Controls("Databaseutilities").Controls("Compact and repair database...").accDoDefaultAction
End Sub

 
Controls("Databaseutilitie s")

Try removing the space and see if it works then.

I don't about stopping the database reopening though.
 
You can select Compact on Close in your database Options. This will not reopen the the Database. Remember the database will only be compacted if no other user has the DB open.
 

Users who are viewing this thread

Back
Top Bottom