copy database on open

chewy

SuperNintendo Chalmers
Local time
Today, 21:11
Joined
Mar 8, 2002
Messages
581
I would like to make a backup copy of my database when the DB is opened. How would I go about this? Would I have to do a shell command to copy the current db and make the copy to a new location. Is this easy or impossible?
 
I kind of get it but am not sure how to call these functions
 
I get that permission error 70. I did what it told me to do.
 
Try this function out.

Function fCopyFile(strFile1 As String, strFile2 As String)

Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
fso.CopyFile strFile1, strFile2, True

End Function

Open the Immediate window or Debug window and type this in.

? fCopyFile(CurrentDb.Name,"c:\backupdb.mdb")

Now hit Enter.
 
wow! What an easy solution. Works great! Thanks!

Now how would I get this to save a copy only once when the Database is opened
 
You mean every time you open the db, copy it to somewhere else? Or do it once for its life time.

If you have a popup form or any form that is open automatically when the db is open, use the function on OnLoad event for the form.

Private Sub Form_Load()
fCopyFile(CurrentDb.Name,"c:\backupdb.mdb")
End Sub

What is the purpose of doing this?
 
I got it to work...but I made it do it icase someone corrupts tthe database and forgets to back it up
 

Users who are viewing this thread

Back
Top Bottom