Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scheduling Compact database

Status
Not open for further replies.

DoniFromMars

Programmer
Aug 10, 2006
23
0
0
US
I'd like to compact my database at a specific time every night without having to do it manually from the menu.
VBA has docmd.RunCommand acCmdCompactDatabase which looks promising but you can’t compact to db that is running the code and I can't find where to specify a different db.
Help!
 
DoniFromMars,
if i remember correctly there is a command line switch to compact the db when you open it. search access help for compact and startup command line options. put the command line in a .bat file and use scheduled tasks to run it when you want.
regards,
longhair
 
You can force 'compact&repair' command action:
Code:
Sub CompactThisDB()
Dim conCompact As Office.CommandBarControl
Set conCompact = CommandBars.FindControl(Id:=2071)
conCompact.accDoDefaultAction
End Sub

combo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top