Back up On exit

silly bugger, didn't have a folder called backup created du!

Thanks t you
 
This is my slightly altered version of the code:

Code:
Dim bckup As FileSystemObject
On Error GoTo Unsuccessful

Dim strBckupName As String
    strBckupName = "BackupDB - " & Format(Date, "mm.dd.yyyy") & " - " & Format(Time, "hhmmss") & ".mdb"

Set bckup = New FileSystemObject
    bckup.CopyFile Application.CurrentProject.FullName, Application.CurrentProject.Path & "\Backups\" & strBckupName, True
Set bckup = Nothing

Beep
MsgBox "Backup was successful and saved @ " & Chr(13) & Chr(13) & Application.CurrentProject.Path & "\Backups" & Chr(13) & Chr(13) & "The backup file name is " & Chr(13) & Chr(13) & strBckupName, vbInformation, "Backup Completed"

End
Unsuccessful:
MsgBox "Backup unsuccessful. Check:" & Chr(13) & Chr(13) & "- The disk you are saving to is not full" & Chr(13) & Chr(13) & "AND" & Chr(13) & Chr(13) & "- That a 'backups' folder has been created in the directory of the active database", vbExclamation, "Backup Unsuccessful"

If it makes it easier people can use this code and it will just find the path and name of the database automatically. All you have to ensure is that there is a folder called Backups in the directory where your database is saved.

Hope this helps,
Jon.
 
Hi

All you had to do was remove the code related to zipping the db. Like this...

Code:
Public Function BackupCopy() 
 
'This function will allow you to copy a db that is open, 
 
'You must set a reference to the 'Microsoft Scripting Runtime' for the CopyFile piece to work! 
 
Dim fso As FileSystemObject 
 
Dim sSourcePath As String 
Dim sSourceFile As String 
Dim sBackupPath As String 
Dim sBackupFile As String 
 
sSourcePath = "C:\Database\" 
sSourceFile = "MyDB.mdb" 
sBackupPath = "C:\Database\Backups\" 
sBackupFile = "BackupDB_" & Format(Date, "mmddyyyy") & "_" & Format(Time, "hhmmss") & ".mdb" 
 
Set fso = New FileSystemObject 
fso.CopyFile sSourcePath & sSourceFile, sBackupPath & sBackupFile, True 
Set fso = Nothing 
 
Beep 
MsgBox "Backup was successful and saved @ " & Chr(13) & Chr(13) & sBackupPath & Chr(13) & Chr(13) & "The backup file name is " & Chr(13) & Chr(13) & sBackupFile, vbInformation, "Backup Completed" 
 
End Function


Hi friend,
I have the a problem while zipping the database.
The onyl difference is i hav writen the script so as i can brouse n select the file which i want to back up n zip.
Find the zip file here http://www.access-programmers.co.uk/forums/showthread.php?p=717418&posted=1#post717418

Can you please share your .mdb file in which you can properly zip the file without producing error?
I shall be thankfull.
 
Hi

As I stated in the top of my fucntion...

You must set a reference to the 'Microsoft Scripting Runtime' for the fso.CopyFile part to work!


Hi friend.
I hav developed a script that can take backup n zip it.
The difference is i can brouse n select the file that i want to back up.

http://www.access-programmers.co.uk/forums/showthread.php?p=717418&posted=1#post717418

The problem im still facing is while zipping the file.
Sm thing is wrong going with the script.
Can you share your .MDB file you made for zipping the database.
I will like to study your concept.

I shall be very thankfull.:o
 
I tried this and had a compile error: user-defined type not defined for the line Dim fso As filesystemobject. Any suggestions?
 

Users who are viewing this thread

Back
Top Bottom