Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access compact and repair via VBA 1

Status
Not open for further replies.

emik

MIS
Jul 24, 2006
80
CA
Hi,

I searched the forums and found some threads, but none of them were able to come up with a solution. I wanted to refresh the topic and see if someone has discovered a way.

Thanks.
 
I forgot to mention.

I have an older program that has a close button with this line of code:

CurrentDb.Properties("Auto Compact") = True

It does compact and repair, but on my current application I get the error that I cannot compact the open database while running a macro or vba.
 
I saw that link before, it does compact the database but it leaves it open. If I put a docmd.quit after that code I get an Access error saying I can't execute code (it starts compacting and then hits the quit command).

My main objective is when the user closes the database it will compact itself.
 
Tools - Options - General Tab. Check Compact on Close. If multiple users are sharing the same database, Access compacts the database when the last user closes it.
 
Alternatively, if you don't want all your users compacting on close (what if you have some users without administrative privileges - that could cause problems compacting) consider an admin tool like the Handy Access Launcher ( that enables you to schedule compacts, repairs and macro runs at regular intervals.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top