Create current daily backup of linked data files

Ease of Use


Version tested with


Submitted by:



The code makes a copy of the file containing the tables etc linked to the database to a different folder for each day of the week 


Where your data is critical and you need it readily available, this code will maintain a current copy for each day of the week in the "spare" space on your disk. Previous copies on any day will be overwritten. The code can be linked to the Quit button as shown, or to any other suitable event. 


instructions for use


Option Compare Database Private Sub Command0_Click() On Error GoTo Err_Command0_Click Backsup DoCmd.Quit Exit_Command0_Click: Exit Sub Err_Command0_Click: MsgBox Err.Description Resume Exit_Command0_Click End Sub Sub Backsup() Dim SourceFile, DestinationFile SourceFile = "C:\Data\MyData.mdb" ' Define source file name. ' Define target file name. DestinationFile = "C:\Data\" & Format(Now(), "dddd") & "\MyData.mdb" FileCopy SourceFile, DestinationFile ' Copy source to target. End Sub

How to use:

  1. Copy the Backsup code above and paste it into the code module of your form
  2. Add the Backsup line to the event that you wish to run the code.

Test the code:

  1. Extract the sample folder onto the C Drive. This will create a folder called Data with seven subfolders
  2. Open TestFile.mdb
  3. Click on the "Quit App and Backup" button
  4. This will create a copy of MyData.mdb into the folder with the name of the day.

Sample File: 32.79KB 

Approved by Jacob Hilderbrand

This entry has been viewed 82 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express