Compact and Repair Database via Macro

A

Akua Aning

Hello Everyone!

I wanted to know if it is possible to compact and repair a
database using a macro (as opposed to manually doing it).
I tried running the following macro:

Action: RunCommand
Command: CompactDatabase

but I received the following error: You can't compact the
open database while running a macro or Visual Basic code.

Is there another way to automate this process?

Thanks for your help!
Akua Aning
(e-mail address removed)
 
E

Eric Bl.itzer

You cannot compact a database using a macro or code. You
can have the application compact everytime you exit it.
In the tools/option menu in the general tab there is
a "Compact on close" check box.

Eric
 
N

Nick Hoare

You can do this in code after a fashion. It is possible to set the
option 'Compact on Close' in code. So on close you make your decision
about whether compacting is needed or was selected and set the option
accordingly. E.g.
If FileLen(CurrentDb.Name) > MAX_APPSIZE Then
MsgBox "The Application file is too bigger it will be compacted"
SetOption "Auto Compact", True
Else
' Does not need compacting yet
SetOption "Auto Compact", False
End If

BTW - if you come across it, SetOption "Auto Compact Percentage" does
not work.
 
M

m wark

Hi!

Did you ever get a resolution to this problem? I just
posted this same question to the Microsoft site today...
We are wanting to do this same function... Please let me
know the details of any solution you discovered...

Thanx! m
 

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