compact and copy a split database

D

Dave

using access 2002, the database is split and when exiting from the main form
i want to do a compact and then copy the backend to a backup location... or
maybe on opening the main form, doesn't really matter. in either case, how
can i compact the backend from the frontend? or do i have to put some code
in the backend to compact it from there?? and will that work when running
with just the runtime not the full access installation?

the second part is how to safely copy it. i have found that the filecopy
command won't work because it sees the be file as locked... however spawning
a batch file with a copy command does copy it.. but that may not be safe if
data hasn't been written yet. is it possible to close the connection to the
be, or is there somewhere in the unload process where the be has been closed
that i still have control from vba to do a filecopy?
 
R

Rick Brandt

Dave said:
using access 2002, the database is split and when exiting from the
main form i want to do a compact and then copy the backend to a
backup location... or maybe on opening the main form, doesn't really
matter. in either case, how can i compact the backend from the
frontend? or do i have to put some code in the backend to compact it
from there?? and will that work when running with just the runtime
not the full access installation?

the second part is how to safely copy it. i have found that the
filecopy command won't work because it sees the be file as locked...
however spawning a batch file with a copy command does copy it.. but
that may not be safe if data hasn't been written yet. is it possible
to close the connection to the be, or is there somewhere in the
unload process where the be has been closed that i still have control
from vba to do a filecopy?

If all bound form/reports are closed and you have no other processes that are
running against the links then you should be able to operate against the BE
file. A good thing to do is test for the BE LDB file using the Dir() function.
If it is present, then the file is still in use. If not, then you can use...

DBEngine.CompactDatabase "Path to BE file" "Path to destination file"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top