Compact the database through VBA

S

Sreedhar

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

Steve Schapel

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
 
S

Sreedhar

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
 

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