Auto Backup

bhelmy

Registered User.
Local time
Today, 21:26
Joined
Dec 6, 2015
Messages
62
Hi all
Need database to make self-backup every day in the same time
 
Schedule a copy job in the windows task scheduler.
 
you need a form. On the form is a text box, txtStart, that holds the Time of which to backup the data. (the backend I hope) txtStart = 21:00

This form has the timer property TIMER INTERVAL = 10000 (10 seconds)
So every 10 seconds vb looks at the time in the text box to see if its time to execute. If so,
it runs the code in ON TIMER event.

The code below goes into the form vbe.
Code:
PRIVATE mbIsRunning as boolean

Private Sub Form_Timer()

If txtStart = Now() And Not mbIsRunning Then
   mbIsRunning = True
   BackupDb
   docmd.close
End If


sub BackupDb()
dim vSrc, vTarg, vName, vTime


vTime = format(now(),"yymmdd-hhnn")
vName = "MyDb-BE.accdb"
vSrc = "\\server\folder\"
vTarg = "\\server\backup folder\" & vTime & "_" & vName 

Copy vSrc, vTarg
end sub
 
What happens if the database isn't open?
 
Copy isn't ideal if the Access database might be open.

If you really want automated backups then best use a server backend such as MS SQL Server.
 

Users who are viewing this thread

Back
Top Bottom