How to Compact and Repair a DB within a Macro ?

G

Guest

Hi Steve,

Thanks for your answer but when I try to do it, I receive the message:

"You can't compact the open database while running a macro or Visual Basic
code.
Instead of using a macro or code, on the tools menu, point to Database
Utilities, and then click Compact/Repair Database."

How can I avoid this message and run the compact from the macro ?

Best regards,

Thomas

[MVP] S.Clark said:
Runcommand RepairDatabase
Runcommand CompactDatabase



Expand AllCollapse All


Manage Your Profile |Legal |Contact Us |MSDN Flash Newsletter
 
N

Nikos Yannacopoulos

Thomas,

Access is not happy to let you compact a database through a macro or code in
the same database, the reason being simply that the database has to be
closed in order to be compacted. The pertinent macro action and VB method
exist for compacting anohter database, not the same one!
If you are working on Access 2000 or later, though, you can just set the
database to compact every time it is closed, by going Tools > Options, tab
General and checking Compact on Close. This should do just fine.

HTH,
Nikos
 
G

Guest

Hi Nikos,
I need your help:
How to compact and repair another DB within a Code?
Can you help me?
thank you
Miriam
 

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