PDA

View Full Version : [SOLVED:] Backup current front-end database



mrojas
09-23-2013, 09:04 PM
I'm having a mental block and I know this has come up before. I'm creating a form with a button that when clicked, it backs up the current front-end database, but can't seem to get my head around it.
If I use FileCopy strDatabaseName, strBackupName I get a "Permission Denied" error
If I use DBEngine.CompactDatabase strDatabaseName, strBackupName I get "You attempted to open a database that is already open by use 'Admin'...":banghead:


Any suggestions?

HiTechCoach
09-24-2013, 10:54 AM
What version of Access?

The short answer is that you really can't properly backup or copy a file when it is open.

This means you will need to close the database before you run your backup software or try to make a copy for the file. One way to do this is to have the front end call a DOS bat/cmd file that copies or backups up the front end and then reopens it. Something similar to FRONT-END AUTO-UPDATE ENABLING TOOL found here: http://www.btabdevelopment.com/ts/freetools

Curious, why you you need to backup or copy the front end?

I deploy all my front ends compiled (MDE/ACCDE) with no local data. There really is no need to back up the local copy of a front end since it can't be changed.. I regular copy a new version of the front end to the local hard drives. The only front end I need to back up is the master copy. I have yet to have the need to do what you are asking in 15+ years deplying Access applicaitions.

mrojas
09-24-2013, 06:05 PM
Thanks for your reply.

What I ended up doing is the following:

Using the Scripting File Object, I created a copy of the database, while opened, giving it a temporary name.
I then took the temporary copy of the database, and using DBEngine.CompactDatabase, I created my compacted backup database.