RC- said:
Hi all, I need to make a backup copy of my database using VBA. I need to give
the backup the same name as the current db and save it a certain drive, I also
need to overwrite the backup that is currently there. I want to be able to do
this by clicking a button.
Does anyone have a routine that can save me some research time?
There is no "proper" way to back up the current file because that means copying
an in-use file and that means the copy could very well be corrupted. Now, in a
split app it is fairly easy to create a routine that copies the data file as
long as no current connections to it exist (assuming single user), but copying
the file that I have open in Access "right now" is never really a good idea. In
fact the built in FileCopy command won't even allow it.
You could shell out to a batch or script file and have it copy the file as I
think those might allow copying of an in-use file. Another option is to have a
routine that launches another app and then closes the existing one. The new app
could check for the lack of an LDB file on the first file in a loop that runs
until satisfied after which the copy is made and then you could have it do a
close this and open that file in the other direction to get back into the
original app.
It would be a lot simpler to just use a proper scheduled backup program.