VB Code:
Private Sub CmdRestore_Click()
On Error GoTo PerErr
'If Db.State = 1 Then
'Db.Close
'set db=nothing ' ---> new additon
'End If
set db=nothing ' ---> new additon
SetAttr App.Path & "\Pcdb.mdb", vbNormal
Kill App.Path & "\pcdb.mdb"
'If Db.State = 0 Then
FileCopy Direc & "\" & FileName, App.Path & "\pcdb.mdb" '& Format(Date, "dd/mm/yyyy") & ".mdb"
MsgBox "Restore completed ", vbInformation, "Restored"
SetAttr App.Path & "\Pcdb.mdb", vbHidden
Exit sub '--> New
PerErr: 'Access Permission (If Database is in use)
If Err.Number = 75 Then
MsgBox "Database is in use. Unable to create backup", vbCritical, "Database
is in use"
Exit Sub
End If
'End If
End Sub