Please, This is a feedback. I used the codes below to write up the restore button, it responds alright but it does really restore the Access objects . My expectation is that by the punch of the restore button, the Access Objects in the software will be deleted and replaced by the Access Objects in the backup file or if the software is blank will updated with the objects in the backup file.
Please, check out the codes and see if you help to edit and so that works as it should.
Private Sub cmdRestore_Click()
Dim strBackup As String
Dim strFullBackup As String
Dim strExt As String
'* do some validataion before executing
If Trim(Me.txtFileName & "") <> "" Then
If Dir(Me.txtFileName) <> "" Then
strExt = (Me.txtFileName)
strBackup = "Backup" & Format(Now(), "_ddmmyyyy_nnss") & strExt
strFullBackup = CurrentProject.Path & "" & strBackup
'* rename original database
'* restore backup
FileCopy Me.txtFileName, CurrentProject.Path & "" & DLookup("OriginalName", "tblBackUpDB")
'* update table
CurrentDb.Execute "Update tblBackUpDB Set [FromBackupName]=" & Chr(34) & (Me.txtFileName) & Chr(34) & ", " & _
"[NewBackUpName] = " & Chr(34) & strBackup & Chr(34) & ", [Cancelled]=0;"
MsgBox "Congratulations !!! Successfully restored database from " & (Me.txtFileName)
MsgBox "Have A Nice Day"
Else
MsgBox "Path or filename not found.", vbOKOnly, "Restore"
Me.txtFileName.SetFocus
End If
Else
MsgBox "Nothing to restore", vbOKOnly, "Restore"
End If
End Sub
Please, check out the codes and see if you help to edit and so that works as it should.
Private Sub cmdRestore_Click()
Dim strBackup As String
Dim strFullBackup As String
Dim strExt As String
'* do some validataion before executing
If Trim(Me.txtFileName & "") <> "" Then
If Dir(Me.txtFileName) <> "" Then
strExt = (Me.txtFileName)
strBackup = "Backup" & Format(Now(), "_ddmmyyyy_nnss") & strExt
strFullBackup = CurrentProject.Path & "" & strBackup
'* rename original database
'* restore backup
FileCopy Me.txtFileName, CurrentProject.Path & "" & DLookup("OriginalName", "tblBackUpDB")
'* update table
CurrentDb.Execute "Update tblBackUpDB Set [FromBackupName]=" & Chr(34) & (Me.txtFileName) & Chr(34) & ", " & _
"[NewBackUpName] = " & Chr(34) & strBackup & Chr(34) & ", [Cancelled]=0;"
MsgBox "Congratulations !!! Successfully restored database from " & (Me.txtFileName)
MsgBox "Have A Nice Day"
Else
MsgBox "Path or filename not found.", vbOKOnly, "Restore"
Me.txtFileName.SetFocus
End If
Else
MsgBox "Nothing to restore", vbOKOnly, "Restore"
End If
End Sub