Backup of Database

  • Thread starter Thread starter Aamer
  • Start date Start date
A

Aamer

I would like to place a botton on a form which will make a backup of the
entire database or just the tables

Can somone help me with the code or how to make a macro
 
On Mon, 11 Jan 2010 05:25:01 -0800, Aamer

You can't really backup yourself because you would be in use.

It sounds like you have not split your database? That would be a
mistake.
Once split you can make a backup from the server using its backup
software.
The front-end doesn't really need to be backed up; if needed you can
simply get a new copy. There typically is no data in the front-end.

-Tom.
Microsoft Access MVP
 
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
 
Back
Top