automated Db backup

R

Rich

Hi,
I'm trying to do a backup of the current Db as the first step of
a macro. Could someone give me the VBA code for that?
Thanks in advance to all who respond.

Rich
 
J

John W. Vinson

Hi,
I'm trying to do a backup of the current Db as the first step of
a macro. Could someone give me the VBA code for that?
Thanks in advance to all who respond.

Rich

As a rule, backing up an open database is A Bad Idea. If it's a multiuser
database it's not a bad idea, it's a disaster waiting to happen!

I'd use Windows tools to keep current backups (daily or more frequent) of the
..mdb/.accdb file external to Access.
 
P

Piet Linden

As a rule, backing up an open database is A Bad Idea. If it's a multiuser
database it's not a bad idea, it's a disaster waiting to happen!

I'd use Windows tools to keep current backups (daily or more frequent) ofthe
.mdb/.accdb file external to Access.

Couldn't he use the Scheduler app ...
http://www.mvps.org/access/modules/mdl0042.htm

to do something like...
run KickEmOut (from Arvin) then
close the DB properly
Quit Access
then...
run the backup using the app that the scheduler runs...
 
J

John W. Vinson

John,
I should have mentioned that this macro runs at night when there is
nobody on the system
Rich

Then don't open Access *AT ALL*. Use Windows Scheduler to simply copy the .mdb
file to the desired backup folder.
 
T

Tony Toews [MVP]

Rich said:
I'm trying to do a backup of the current Db as the first step of
a macro. Could someone give me the VBA code for that?
Thanks in advance to all who respond.

When the user exits the FE attempt to rename the backend MDB
preferably with todays date in the name in yyyy-mm-dd format. Ensure
you close all bound forms, including hidden forms, and reports before
doing this. If you get an error message, oops, its busy so don't
bother. If it is successful then compact it back.

See my Backup, do you trust the users or sysadmins? tips page for more
info.
http://www.granite.ab.ca/access/backup.htm

Tony
 
T

Tony Toews [MVP]

John W. Vinson said:
As a rule, backing up an open database is A Bad Idea. If it's a multiuser
database it's not a bad idea, it's a disaster waiting to happen!

I'd use Windows tools to keep current backups (daily or more frequent) of the
.mdb/.accdb file external to Access.

I disagree with this rule in some situations. If this is in a corp
environment where the data MDB is on a server that's being backed up
then I agree with you.

However one of my apps is frequently used by a single computer in the
fleet maintenance garage. And the folks using it frequently put a
copy on a USB drive and copy it to their computer at home. In this
environment having a backup command button makes a lot of sense.

I also put the data mdb in a folder off the My Documents folder. The
reasoning being that maybe, just maybe, they'll backup the My
Documents folder on a monthly or semi annual basis. <smile> Or when
their hard drive starts to fail the tech will manage to pull that
folder off the hard drive onto the new one.

Tony
 

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