Aamer,
Step1: make sure you split your database.
Step 2: make a button on a form to call this code
Here's a function I made to backup the back-end database.
My back-end db is always called:
"Donation_BE.accdb"
Probably have to tweak the code a little but hope you get the idea.
OpenForm is another function that opens certain forms I have, just open the
main form in your db.
Public Function BackupBackEnd()
On Error GoTo Err_BackupBackEnd
Dim strBackEndFullPath As String
Dim strNewPath As String
Dim i As Integer
Dim intCount As Integer
strBackEndFullPath = GetDataPath("tblContact") 'full DB path and name
strNewPath = Replace(strBackEndFullPath, "Donation_BE.accdb", "") &
"DonationBackup_" & Format(Now(), "yyyymmdd") & ".accdb" 'remove DB name
from path and add filename with date
If (MsgBox("Ok to backup your data to: " & strNewPath, vbOKCancel,
"Confirm Backup is OK to Begin") = vbOK) Then
'close all forms (so back-end is not open)
intCount = Forms.Count - 1
For i = intCount To 0 Step -1
DoCmd.Close acForm, Forms(i).Name
Next
'copy file
FileCopy strBackEndFullPath, strNewPath
MsgBox "Backup of database created: " & strNewPath
Call OpenForm("frmContactList", 1)
End If
Exit_BackupBackEnd:
Exit Function
Err_BackupBackEnd:
Select Case Err.Number
Case 70, 3356
MsgBox "Cannot backup just now - the database is already open.
Possibly another user is using the database?"
Case 68, 71, 76
MsgBox "Backup failed! Backup folder is not available or cannot
be created or device is not ready."
Case Else
MsgBox "Error " & Err.Number & " (" & Err.Description & ")"
End Select
Resume Exit_BackupBackEnd
End Function
HTH,
Mark Andrews
RPT Software
http://www.rptsoftware.com
PS: If you want to see it in action download and install the evaluation from
http://www.donationmanagementsoftware.com