Compact the database through VBA

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

Guest

Please help !

I want to compact the database each time the application is opened for 10
times 'cos I create and delete objects such as tables and reports on the fly.
I'm logging the open count and want to ask the user if he wants to compact
now, and based on the response, compact the database through code.
But, when I run the following line, I get an error message stating that I
can't compact an open database by using a macro or code.

runcommand accmdCompactDatabase

Hope someone helps me to a workaround.
 
Sreedhar,

I generally use the built-in 'Compact On Close' function, via the
General tab from the Tools=>Options menu.

However, I understand that this code works:
CommandBars("Menu Bar").Controls("Tools").Controls("Database
utilities").Controls("Compact and repair database...").accDoDefaultAction
 
Steve,

Thanks a lot. It works.

--
Sreedhar


Steve Schapel said:
Sreedhar,

I generally use the built-in 'Compact On Close' function, via the
General tab from the Tools=>Options menu.

However, I understand that this code works:
CommandBars("Menu Bar").Controls("Tools").Controls("Database
utilities").Controls("Compact and repair database...").accDoDefaultAction
 
Back
Top