Automatic Database Backup

  • Thread starter Thread starter Ayo
  • Start date Start date
A

Ayo

Is it possible to right code to automatically backup a database? And if so
how, or where, can I get information on this?
 
Hi

There are a few way to do this. I have windows scheuler doing this on all
my databases (at 1 min past midnight each day). Open Scheduled Tasks (it's
in the control panel). It's very simple and not likely to go wrong
 
Thanks Wayne.
So I take it that, there is no way to write that into a VBA code? I will
try the scheduler in windows>
 
Yes of course you can it's simple but a REALLY BIG mistake.
You could use something like
Dim strOldPathName As String
Dim strNewPathName As String
myfile = Dir("C:\Path to DB here.mdb")
If myfile <> "" Then
Kill "C:\Path to BackUpName here.mdb"
strOldPathName = "C:\Path to DB here.mdb"
strNewPathName = "Some Drive:\BackupName.mdb"
strOldPathName, strNewPathName
Else
strOldPathName = "C:\Path to DB here.mdb"
strNewPathName = "Some Drice:\BackupName.mdb"
End If

BUT DON'T
You can't backup or compact a DB that someone may be working on or isn't
open in exclusive mode (well you "can" but it's not reliable - and thats not
the point of a backup). Check out the MS knowledge base for a load of
reasons to NOT do this.

The best way is to either
Use a DB that is set up to backup all your other DB's and run the code from
there
Use scheluder (the best and simplest way to do this)
Use this method on the MVP site
http://www.mvps.org/access/modules/mdl0045.htm
 
Back
Top