Compact and Repair Database (1 Viewer)

jereece

Registered User.
Local time
Today, 14:37
Joined
Dec 11, 2001
Messages
300
This morning my Work Order database was giving a "Invalid Argument (3001)" error message on one of my queries. After some troubleshooting, I figured out it something was corrupt. So I ran Compact and Repair and this fixed my problem. The people who use this database are not very familiar with Access so I thought I would write a macro and assign it to a button where they can periodically do a compact and repair. Well sure enough there are built in macro Run Commands for "CompactDatabase" and "RepairDatabase". So I made a macro to close the open one open form, then run RepairDatabase, then run CompactDatabase. However when I run the macro, I get the error message "You can't compact the open database while running a macro". Well why are these run commands built into Access macros if you can't do it?

Am I doing somethign wrong or is there an easier way have novice Access users the ability to run compact and repair?

Thanks,
Jim
 

___

¯¯¯¯¯
Local time
Today, 14:37
Joined
Nov 27, 2003
Messages
595
If you are using A2K or above you can compact & repair every time the db closes.
Goto Tools >> Options >> General Tab and select 'Compact On Close'

HTH
 

___

¯¯¯¯¯
Local time
Today, 14:37
Joined
Nov 27, 2003
Messages
595
Or, if you really want to compact from the click of a button, use the following in the OnClick event.
Code:
        SendKeys "%(TDC)", False

HTH
 

TheEvilBankers

Registered User.
Local time
Today, 14:37
Joined
Aug 13, 2003
Messages
33
___ said:
If you are using A2K or above you can compact & repair every time the db closes.
Goto Tools >> Options >> General Tab and select 'Compact On Close'

HTH


It works great if you are the only one in a database at the time you close it. We tried it with databases that usually have more than one databases and kept geting db(some number) because it could not replace it because it was open.

So we only have some databases compact and repair on close and others we do by hand.

Depends on how your office is setup.

We also have assigned people to compact and repair the databases when the network goes down or we have the power go off.

Kim
 

jereece

Registered User.
Local time
Today, 14:37
Joined
Dec 11, 2001
Messages
300
Great list of examples! I will have a great time checking them out. The autobackup that includes a repair feature will probaby just what I need. That way I can run it over night when no one is using the database.

Thanks!

Jim
 

gfilis

New member
Local time
Today, 09:37
Joined
Jan 3, 2013
Messages
1
I have been trying to find a better solution, but for now I am using SendKey("FMC") to compact and repair my database from within the VBA code. One problem is that if another application is open and has the focus it receives the "FMC" keystrokes rather than the Access app. It works as long as Access has the focus.
 

CW3

New member
Local time
Today, 09:37
Joined
Nov 26, 2014
Messages
1
Or, if you really want to compact from the click of a button, use the following in the OnClick event.
Code:
        SendKeys "%(TDC)", False

HTH
Works Like a Charm! Exactly what I needed! Thanks!:)
 

Users who are viewing this thread

Top Bottom