Track Last Backup Date (1 Viewer)

Milothicus

Registered User.
Local time
Today, 03:46
Joined
Sep 24, 2004
Messages
134
I'm trying to display the date that the back end database was last backed up on the same form as a backup-button. unfortunately, you can't use the backup command if a bound form is open, and to show the last date, the form needs to be bound to my backupdate table.

here's my backup code if it helps:

On Error GoTo Err_Backup
Dim strMsg As String, strTitle As String
Dim strSource As String, strDest As String
Dim strError As String
'
strMsg = "The Backup of the Database was Successful."
strTitle = " Backup Complete"
'
BeginBackup:
DoCmd.Hourglass True

' Path where backend database is located
strSource = "Q:\Enquiry Book\Enquiry Book_be.mdb"

' Destination where data file is to be copied
strDest = "Q:\Enquiry Book\backups\Enquiry Book_be " & Date$ & ".mdb"

FileCopy strSource, strDest
DoCmd.Hourglass False
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO tblBackup (backupdate, backuptime) VALUES ('" & _
Date & "', '" & Time & "')"
DoCmd.SetWarnings True
' Backup has completed - Give Successful Completion Message
MsgBox strMsg, vbInformation + vbOKOnly, strTitle

Exit_Backup:
Exit Sub

Err_Backup:
Select Case Err.Number
Case 61
strError = "The Floppy Disk is full, Cannot Save to this Disk." _
& vbCrLf & vbCrLf & "Insert a New Disk then Click ""OK"""
If MsgBox(strError, vbCritical + vbOKCancel, " Disk Full") = vbOK Then
Resume BeginBackup
Else
Resume Exit_Backup
End If
Case 70
strError = "The File is currently open." & vbCrLf & _
"The File can not be Backed Up at this time."
MsgBox strError, vbCritical + vbOKCancel, " File Open"
Case 71
strError = "There Is No Disk in Drive" & vbCrLf & vbCrLf & _
"Please Insert Disk then Click ""OK"""
If MsgBox(strError, vbCritical + vbOKCancel, " No Disk") = vbOK Then
Resume BeginBackup
Else
DoCmd.Hourglass False
Resume Exit_Backup
End If
Case Else
DoCmd.Hourglass False
MsgBox Err.Number & vbCrLf & Err.Description
Resume Exit_Backup
End Select

and here's my last backup display code:

Set db = CurrentDb
Set rst = db.OpenRecordset("tblbackup")
DoCmd.GoToRecord , "", acLast
Me.txtLstBkpDt = BackupDate
Me.txtLstBkpTm = BackupTime

which fills in two text boxes with the last date and time. both the 'me' syntax and the forms!frmbackup..... only work if the form is bound to the table, and if it's bound, i can't run the update code.

I tried an acclose and acopenform "frmbackup" around the actual backup code, and that didn't work either.

any suggestions?
 

Milothicus

Registered User.
Local time
Today, 03:46
Joined
Sep 24, 2004
Messages
134
would it be possible to open a new form that only has the backup button, close the original form, automatically press the backup button, close the new form, and reopen the original?

how would i code this?
 

Milothicus

Registered User.
Local time
Today, 03:46
Joined
Sep 24, 2004
Messages
134
nudge.....
 

Users who are viewing this thread

Top Bottom