Compact and Repair Back End DB?

  • Thread starter Thread starter Henry Smith
  • Start date Start date
H

Henry Smith

I have a AC2000 DB with a front end and a back end. Have set both DB,
options dialog, to compact-on-exit. With the front end application, the
compact-on-exit function works as advertised, i.e., the front end actually
performs the compact process each time I click the exit button. Since the
back end is actually never opened the compact process does not occur when I
click the exit button. Over time the back end file size progressively
becomes larger than it should because the compact process is never run.
How can I have the back end perform a compact process when I exit the front
end?

Any suggestions will be greatly appreciated.
Cheers,
Henry
 
In order to do this the database must not be in use. So this code will not
work from your front end database that has its tables linked to the back
end. You will need to have code in yet another database that is NOT linked
to your back end. The command to actually do the compact is pretty straight
forward.
DBEngine.CompactDatabase strSourceFilename, strDestFilename
However you probably want to protect your self by doing the Compact on a
copy of your database, so... you probably want to do something like:

Insure the database exists
Attempt to open the database exclusively to insure it is not in use
Make a safe copy of the database just in case
Compact the safe copy
Copy the new compacted database over top of the origional database

Ron W
 
Back
Top