Results 1 to 4 of 4
  1. #1
    WAVP375 is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Dayton Ohio
    Posts
    171

    Backing up database

    I am using the following code to back up the DB on exiting. It works fine and each time overwrites the backup. I haven't found a way to change the code to write to a new backup each time. I am wanting multiple backups. Any suggestions?

    Thanks

    Dim DestFile
    Dim strDestFileName
    Dim strNow


    Dim aSFO
    strNow = Year(Date) & "-" & Month(Date) & "-" & Day(Date) & "-" & Hour(Now) & "-" & Minute(Now)
    strDestFileName = "SoinVolunteerDB_Backup_" & strNow & ".accdb"
    DestFile = "S:\Soin Volunteer Training Access Data\TrainingDBBackup" & strDestName
    SourceFile = "S:\Soin Volunteer Training Access Data\NewVolunteerTraining.accdb"
    Set aFSO = CreateObject("Scripting.FileSystemObject")
    aFSO.CopyFile SourceFile, DestFile
    DoCmd.SetWarnings True
    MsgBox "Date Base Has Been Successfully Backed Up"


    'Exit Access
    DoCmd.Close
    DoCmd.Quit

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    Use a timestamp in the target file name.
    format(now,"yyyymmdd-hhnn")

  3. #3
    WAVP375 is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Dayton Ohio
    Posts
    171
    Doesn't the strNow give me the timestamp?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    See a problem?

    strDestFileName = "SoinVolunteerDB_Backup_" & strNow & ".accdb"
    DestFile = "S:\Soin Volunteer Training Access Data\TrainingDBBackup" & strDestName
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 9
    Last Post: 06-23-2018, 10:25 PM
  2. Replies: 2
    Last Post: 04-27-2016, 06:20 AM
  3. Replies: 1
    Last Post: 07-01-2015, 04:18 AM
  4. Replies: 1
    Last Post: 03-21-2015, 11:55 AM
  5. Backing out of a split form
    By Reaper in forum Programming
    Replies: 9
    Last Post: 11-22-2011, 02:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums