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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compact and Repair database

Status
Not open for further replies.

Elamranii

MIS
Feb 1, 2005
57
US
Hi,
Does anybody know of a code I can use to companct and repair a database once a week. Let's say every Friday at 8PM?
Thanks in advance
Ismail
 
First, you need to set up a process which opens a database, compacts it, and closes it again. You can write this into a command (.cmd) file:
Code:
C:\PathToAccess\MsAccess.exe X:\PathToDatabase\MyDatabase.mdb /compact
Example: if you are running Office 2000, your database is called Example.mdb, and it is stored in C:\Databases, then you would write (all on one line):
Code:
"C:\Program Files\Microsoft Office\Office\MsAccess.exe" C:\Databases\Example.mdb /compact
Notice the double quotes, which are needed as the path contains spaces.

Test this command file, to make sure it works correctly.

Note that if you use user and group security in your database, you will need to set up a dummy user, and get the command file to log in as this user. See Startup command-line options in Access help for details of this.

Once you have a working command file, you can schedule it to run at a specific day / time using a scheduler program. For example, Windows XP contains a task scheduler, complete with a set-up wizard, which you can use to run your command file as required.

The best place to schedule from, would be the server containing the database file, if you have rights to do this. This is because servers are generally left on 24/7, so you don't need to remember to leave a workstation running!

I hope that this information helps you.

Bob Stubbs
 
I am going to try it and I'll let you know if it works.
Thanks for your help
Ismail
 
Hi,
I just tried your method and it worked. Thanks a lot for your help.
Ismail
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top