How to Compact and Repair a DB within a Macro ?

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
Hi Nikos,
I need your help:
How to compact and repair another DB within a Code?
Can you help me?
thank you
Miriam
 
Back
Top