Compact and Repair ...

RexesOperator

Registered User.
Local time
Today, 12:22
Joined
Jul 15, 2006
Messages
604
Can compact and repair be set up to run either on a specified day of the week (for example every Monday), or day of the month (for example the first of each month)?

Alternatively can I have it run automatically when the database is closed?

If so, how would it be done?

I am using A2003 with Windows XP.
 
Can compact and repair be set up to run either on a specified day of the week (for example every Monday), or day of the month (for example the first of each month)?
I have a form which opens first when the Db opens and closes last when the Db closes. As part of it's 'On Close' event it checks what day of the week it is and, if it's a Friday, runs
DoCmd.RunCommand acCmdCompactDatabase.
Alternatively can I have it run automatically when the database is closed?
Go to Tools - Options - General and check 'Compact on Close'
 
I have a form which opens first when the Db opens and closes last when the Db closes. As part of it's 'On Close' event it checks what day of the week it is and, if it's a Friday, runs
DoCmd.RunCommand acCmdCompactDatabase.

This is what I'm after. Thanks.
 
Sooner or later it will blow up instead of compacting. How about a bit of insurance. Run a batch file Sunday night with Windows scheduler to copy it somewhere else. Open notepad, type - copy "c:\directory 1\mydb.mdb" "C:\directory 2\mydb.mdb" - and save it as "backup.bat". Use the inverted commas to avoid notepad saving the file with a txt extension.

Chris B
 
Instead of running DoCmd.RunCommand acCmdCompactDatabase from a form, can I run it with the macro that opens the db? Would that prevent the blow-up?
 
You don't want to compact on opening. The database would go into a non-ending cycle as it closes to compact then reopens. So, if you compacted on opening, it would open, then compact which closes it and then reopens it and then would compact which would close it and then reopen it and so on, and so on.
 
Sounds like the energizer bunny that keeps going and going and going.

OK - so can I run it on Exit?

BTW - I had a look at your site and I really like it - especially the Snag-it tutorials.
 
Thanks - I read the article and I will think about this before I decide to implement it. I retire in 15 months, and the person responsible for the database will not have any Access experience other than what I teach him about the database itself (the blind leading the blind). I was thinking this might be a way to automate one more task for him. But I will save it for later.
 
Even if you don't compact automatically you still should have a backup strategy in place. Access can corrupt at any time, you don't have to compact to have it occur. An excellent freeware prog for this is Cobian Backup (There are many others). This can be scheduled as required and dates each folder that it creates so you can easily retain a backup history. http://www.cobian.se/

Chris B
 
Eventually the program will be downloaded to an Oracle server and maintained by IT database types - it just won't happen in my employment lifetime (did I mention I retire in 15 months, but who's counting? - Yiipppeee!).

I already have a three-way back up plan: external Maxtor hard drive, network virtual drive and I keep another copy on my external Maxtor hard drive at home. I already do c/r once a week on all three copies, so I should be good to go.

"Access can corrupt at any time."

It should bother us that we use such an unstable program so blithely!
 
"Access can corrupt at any time."

It should bother us that we use such an unstable program so blithely!
The MAJORITY of the problem lies in that people don't understand how Access works and what the "Kryptonite" points are. Many just move along under the assumption that you can do whatever you want and are baffled when Access corrupts.

Yes, it is true that Access can corrupt at any time, but so can any of your Operating System files. There are things you can do to reduce the risk and therefore it isn't an inevitable occurance. However, most people will do things with Access that actually increase their potential for corruption and, if told about them, are hesitant to do the things that would reduce that risk. So, Access gets the bad rap.
 

Users who are viewing this thread

Back
Top Bottom