Making a copy of the database.

  • Thread starter Thread starter JJ
  • Start date Start date
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
 
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
 
Sorry I think this is the better way

Private Sub Command10_Click()

FileCopy "sourcefile", "destinationfile"

End Sub

Jim
 
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
 
Back
Top