Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Backup-roll back.. 1

Status
Not open for further replies.

thetambarineman

Technical User
Feb 29, 2000
63
GB
Hi all,

having real problems with an app that i want to develop-
thing is i want to create a backup form which will allow the user to roll back to a back up which was created say 3 weeks ago (via clicking on a list box) the files are MDB and i want them to go into a certain location when i select them - oh yeah and the files are usually held in the root directory - under "C:\Backups\"

thanks in advance..

Paul.. [sig][/sig]
 
Paul,

When you make the backup (ie, copy the file to C:\Backups), you would probably want to date stamp it, like Backup20001018, where the date is in yyyymmdd format. This way, the backup filenames can be loaded into the listbox and they can easily be sorted as newest or oldest on top.

To restore the file, try renaming the current file, so it still exists for the time being (for the obligatory user statement of "Oh, I didn't really want to do that!"), and copying the file to be restored in the production directory with the proper filename.

Private Sub Command1_Click()

Const CurrFilePath = "C:\"
Const CurrFileName = "Db1.mdb"

Dim FSO As Scripting.FileSystemObject
Dim CurrFile As Scripting.File
Dim BackupFile As Scripting.File

'make sure an item was selected
If (List1.ListIndex = -1) Then Exit Sub

Set FSO = New FileSystemObject

'rename the current file
Set CurrFile = FSO.GetFile(CurrFilePath & "\" & CurrFileName)
CurrFile.Move CurrFilePath & "\" & "CurrBackup.mdb"

Set BackupFile = FSO.GetFile("C:\Backups\" & List1.List(List1.ListIndex))
BackupFile.Copy CurrFilePath & "\" & CurrFileName

End Sub

This example utilizes the MS Scripting runtime dll, Scrrun.dll, for the FileSystemObject and File objects. I had to manually load it into VB by clicking on the Browse button on the References window and browsing to it, because it didn't automatically load in my references list.

Good luck!

Steve

[sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top