Making a copy of the database.

J

JJ

How would I let a user make a copy of the database that they are in. I
would like a button that till open a form that will have a folder path (I
know how to do this.), but what code would you use on the button to tell it
to make a copy of the database in the folder the the user selected. Also if
the file already excists then overwrite it with no prompts.


Thanks
 
J

Jim/Chris

Naturally you cannot be in the database. You can copy the
back end because you can't replace a file in use. Here is
the code behind the button.

fso.copyfile "input file name", "output file name"

Jim
 
J

Jim/Chris

Sorry I think this is the better way

Private Sub Command10_Click()

FileCopy "sourcefile", "destinationfile"

End Sub

Jim
 
J

JJ

This is what I have so far, but how do I tell it to copy the back-end file,
or how do I tell it to close the db, copy, and then reopen.

Option Compare Database

Private Sub cmdBackup_Click()
Dim SourceFile, DestinationFile

SourceFile = CurrentDBPath
DestinationFile = CurrentDBDir
FileCopy SourceFile, DestinationFile

End Sub

Private Sub cmdBuild_Click()
Dim strFolder As String
strFolder = BrowseFolder("Please select a new folder location for all
backups.")
If Not strFolder = vbNullString Then
Me.txtDest = strFolder
End If
End Sub
Private Sub cmdCancel_Click()
On Error GoTo Err_cmdCancel_Click


DoCmd.CLOSE

Exit_cmdCancel_Click:
Exit Sub

Err_cmdCancel_Click:
MsgBox Err.Description
Resume Exit_cmdCancel_Click

End Sub

Private Sub Command7_Click()
Dim strFolder As String
strFolder = BrowseFolder("Please select a new folder location for all
backups.")
If Not strFolder = vbNullString Then
Me.txtSource = strFolder
End If

End Sub

Private Sub Form_Load()
Me.txtSource = CurrentDBPath
Me.txtDest = CurrentDBDir
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top