Retrieving Database Backups (1 Viewer)

Terry Lawson

Registered User.
Local time
Today, 07:46
Joined
Mar 1, 2010
Messages
12
Hi all

I have a database that on closure automatically generates a backup from the following code:

Option Compare Database
Option Explicit

Dim fso As Object
Dim sSourcePath As String
Dim sSourceFile As String
Dim sBackupPath As String
Dim sBackupFile As String


Private Sub CloseButton_Click()
DoCmd.Close acForm, "Backup Database"
End Sub

Private Sub OKButton_Click()
'find the correct directory for export
sSourcePath = DLookup("[Value]", "Control File", "[ID]=6")
sSourceFile = "Publications.mdb"
sBackupPath = DLookup("[Value]", "Control File", "[ID]=7")
sBackupFile = "Publications Backup " & Format(date, "yymmdd") & Format(Time, "hhmm") & ".mdb"
Set fso = CreateObject("Scripting.FileSystemObject")
fso.CopyFile sSourcePath & sSourceFile, sBackupPath & sBackupFile, True
Set fso = Nothing
MsgBox "Backup was successful and saved in " & Chr(13) & Chr(13) & sBackupPath & Chr(13) & Chr(13) & "The backup file name is " & Chr(13) & Chr(13) & sBackupFile, vbInformation, "Backup Completed"

DoCmd.Close acForm, "Backup Database"
End Sub

I cannot and will not claim any originality for the above!!

Control File ID 6/7 retrieve the appropriate directories

My question is how do I perform the following steps:
1. Retrieve the LAST saved version from the backup directory from the database that is currently open.
2. Replace the current version with the backup version
3. Transfer control to the backup version
4. Permanently delete the old current version

Regards

Terry Lawson
 

Users who are viewing this thread

Top Bottom