Compacting Database

B

BobV

Group:



I have added the code below to to my application. The code forces my
database to be compacted. The code runs fine when I run it under the full
version of Access 2002. However, when I run the code under the Access 2002
Runtime, I get an error message that says:



"You can't exit your program now. If your're running a Visual Basic module
that is using OLE or DDE, you need to interrupt the module."



I do not get the error when I execute the code with my application running
under the full version of Access 2002. Any ideas on how to fix the code so
that it will run without producing an error under the Access 2002 Runtime?



'COMPACT DATABASE NOW

Public Sub CompactDB()

On Error Resume Next

CommandBars("Menu Bar"). _

Controls("Tools"). _

Controls("Database utilities"). _

Controls("Compact and repair database..."). _

accDoDefaultAction

End Sub



Thanks,

BobV
 
K

Klatuu

I think your best bet is to just use the Compact on Close option under
Tools-->Options General Tab. I do this for both the Front End and Back End
databases. When a user closes his copy of the FE, it will compact and repair
his copy. For the BE, It is opened when the first user opens it, but it does
not close until the last connected user closes his front end. Compiling via
code has always had more problems that benifits.
 
B

BobV

Klatuu:

Thank you for the advise. I made a change to the program so that the user
can choose to have the database compacted upon exit it they wish.

I wish there was a way to make the other code work with the Access 2002
Runtime without giving an error message (see my prior message).

Thanks,
BobV
 

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