A
Afrosheen
I'm trying to backup my database through programming. The problem is I get an
error message saying: You can't compact the open database while running a
macro or VB program. I can run the File Maintenance form by its self and the
program will work fine. When I run it through the Main Menu form which
accesses the File Maintenance form then I get the message.
Here is the programming.
'---------------------------------------------------------------------------------------
' Procedure : cmdbackup_Click
' Author :
' Date : 9/8/2008
' Purpose :
'---------------------------------------------------------------------------------------
'
Private Sub cmdbackup_Click()
Dim strSQL
On Error GoTo cmdbackup_Click_Error
Select Case MsgBox("1} You'll be sent to the default folder. " _
& vbCrLf & "2} Select the last file with a date
attached. Right click on it and select delete. " _
& vbCrLf & "3} Answers any prompts. The file will
be deleted." _
& vbCrLf & "4} Click SAVE. After you've done the
back up the program will restart." _
& vbCrLf & " " _
& vbCrLf & "Note: The process will about 1-2
Minutes." _
, vbOKCancel Or vbInformation Or vbDefaultButton2,
Application.Name)
Case vbOK
strSQL = "UPDATE tblbackup SET tblbackup.bkdate = now()"
CurrentDb.Execute strSQL, dbFailOnError
BackupDatabase 'Backs up the database
Case vbCancel
Exit Sub
End Select
On Error GoTo 0
Exit Sub
cmdbackup_Click_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
cmdbackup_Click of VBA Document Form_Form2"
End Sub
Because of who I'm writing this for is not computer savy, I'd like it to
delete the last backup and create a new back up. I don't know if this can be
done. If not then we'll have to deal with it.
Thanks for reading my post
error message saying: You can't compact the open database while running a
macro or VB program. I can run the File Maintenance form by its self and the
program will work fine. When I run it through the Main Menu form which
accesses the File Maintenance form then I get the message.
Here is the programming.
'---------------------------------------------------------------------------------------
' Procedure : cmdbackup_Click
' Author :
' Date : 9/8/2008
' Purpose :
'---------------------------------------------------------------------------------------
'
Private Sub cmdbackup_Click()
Dim strSQL
On Error GoTo cmdbackup_Click_Error
Select Case MsgBox("1} You'll be sent to the default folder. " _
& vbCrLf & "2} Select the last file with a date
attached. Right click on it and select delete. " _
& vbCrLf & "3} Answers any prompts. The file will
be deleted." _
& vbCrLf & "4} Click SAVE. After you've done the
back up the program will restart." _
& vbCrLf & " " _
& vbCrLf & "Note: The process will about 1-2
Minutes." _
, vbOKCancel Or vbInformation Or vbDefaultButton2,
Application.Name)
Case vbOK
strSQL = "UPDATE tblbackup SET tblbackup.bkdate = now()"
CurrentDb.Execute strSQL, dbFailOnError
BackupDatabase 'Backs up the database
Case vbCancel
Exit Sub
End Select
On Error GoTo 0
Exit Sub
cmdbackup_Click_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
cmdbackup_Click of VBA Document Form_Form2"
End Sub
Because of who I'm writing this for is not computer savy, I'd like it to
delete the last backup and create a new back up. I don't know if this can be
done. If not then we'll have to deal with it.
Thanks for reading my post