The below piece of code, which backs up the database which is currently open by opening another database, has suddenly stopped working in Access 2000 - it gives a "permission denied" error and the option to debug the code. The Visual Basic editor indicates that it is the line which copies the database which is causing the problem. The odd thing is that it was previously working fine.
It seems to have suddenly stopped closing the database to be copied after opening the new one (failing to reach the DoCmd.Quit acSave line), causing the second database to refuse to copy the first because the first is still open.
Any help would be much appreciated.
Function OpenNewDatabase(strDatabase As String)
Dim appAcc As Access.Application
Set appAcc = New Access.Application
appAcc.Visible = True
appAcc.RunCommand acCmdAppMaximize
appAcc.OpenCurrentDatabase (strDatabase)
appAcc.UserControl = True
End Function
Private Sub Command11_Click()
If MsgBox("DO YOU WANT TO BACK UP THIS DATABASE?", vbYesNo) = vbYes Then
DoCmd.SetWarnings False
OpenNewDatabase ("D:\[PATH]\Backup.mdb")
DoCmd.Quit acSave 'close current DB'
End If
End Sub
It seems to have suddenly stopped closing the database to be copied after opening the new one (failing to reach the DoCmd.Quit acSave line), causing the second database to refuse to copy the first because the first is still open.
Any help would be much appreciated.
Function OpenNewDatabase(strDatabase As String)
Dim appAcc As Access.Application
Set appAcc = New Access.Application
appAcc.Visible = True
appAcc.RunCommand acCmdAppMaximize
appAcc.OpenCurrentDatabase (strDatabase)
appAcc.UserControl = True
End Function
Private Sub Command11_Click()
If MsgBox("DO YOU WANT TO BACK UP THIS DATABASE?", vbYesNo) = vbYes Then
DoCmd.SetWarnings False
OpenNewDatabase ("D:\[PATH]\Backup.mdb")
DoCmd.Quit acSave 'close current DB'
End If
End Sub