Back up database using VBA code

Rob500

Registered User.
Local time
Today, 00:36
Joined
Mar 19, 2007
Messages
10
Hi there guys

Basically, I have finished a mammoth sized database and I'm now thinking of what I can just bolt on to the end of it. I want to code a way to back up the database using VBA code; I've seen it done so I know it's possible.

I was going to put a button on the main switchboard to back up the database, but I spent ages designing it and I would mess up my perfect formatting. What I have done instead is change the coding of the Quit button so it is now like this:

Code:
Private Sub btnQuitApplication_Click()
Dim msgBackup As Integer
msgBackup = MsgBox("Do you wish to back up the system first?", vbYesNoCancel + vbQuestion, "Back up first?")
If msgBackup = 7 Then
    DoCmd.Quit
ElseIf msgBackup = 6 Then
FileCopy "source.mdb", "destination.mdb"
End If
End Sub

Obviously source and destination are the paths of the actual database.

However, when this code is run, I get a run time error #70, permission denied.

What can I do to overcome this problem?

Many Thanks
 
Have you already searched this Forum on Backup?
 
Hi there guys

Basically, I have finished a mammoth sized database and I'm now thinking of what I can just bolt on to the end of it. I want to code a way to back up the database using VBA code; I've seen it done so I know it's possible.

I was going to put a button on the main switchboard to back up the database, but I spent ages designing it and I would mess up my perfect formatting. What I have done instead is change the coding of the Quit button so it is now like this:

Code:
Private Sub btnQuitApplication_Click()
Dim msgBackup As Integer
msgBackup = MsgBox("Do you wish to back up the system first?", vbYesNoCancel + vbQuestion, "Back up first?")
If msgBackup = 7 Then
    DoCmd.Quit
ElseIf msgBackup = 6 Then
FileCopy "source.mdb", "destination.mdb"
End If
End Sub

Obviously source and destination are the paths of the actual database.

However, when this code is run, I get a run time error #70, permission denied.

What can I do to overcome this problem?

Many Thanks

I use an MS ACCESS Backup routine I got from Helen Feddema's site
http://www.helenfeddema.com/

There is a comment in the code that says
"' Must set security properties of the mdb (inherit)
' else you'll get permission error #70"
 
I just use a .bat file

c:
cd\Documents and Settings\John\My Documents
copy Viper.mdb \\378sue\mydocuments
copy Viper.mdb c:\
copy Viper.mdb j:
copy Viper.mdb k:
copy Viper.mdb \\378mike\c

That is copying the DB to the c: on the computer form where the .bat file is run and external HDs j: and k: and two of the computers on the network
 

Users who are viewing this thread

Back
Top Bottom