Results 1 to 8 of 8
  1. #1
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,365

    Roll Back Database File

    Hi Guy's, you have guessed from the title does a single db front end file have a roll back option ?

    I have done about 5 hours work on some code not knowing I had to dash away from it quickly as something urgent cropped up, perhaps 9 times out of 10 isn't a problem but !!!!

    pc has decided it wants to do an update before i could come back to it, now lost the 5 hours work done....

    IS there a roll back for a db front end file ?

    What i should have done is every so often throughout working on it is click the save button but hindsight is a wonderful event

    Thank you

  2. #2
    Join Date
    Apr 2017
    Posts
    1,792
    Yes, it is! Usually it is defined as backup file

  3. #3
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,365
    Thank you ArvilLaanamets

    Do i need to generate the backup file from the existing file that has the lost code ?

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    No, You make a copy before even touching the DB.
    So find your last saved backup.

    You *might* be lucky if you examine file history for the file, but seriously you should back up regularly and often, depending on how much effort it will take to recreate from scratch.

    https://www.google.com/search?q=enab...hrome&ie=UTF-8
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,365
    Hi WGM, couldn't agree more, even if i only pressed the floppy disc save button, probably 9 out of 10 its ok but PC wanted to reboot without phoning me up to say

    Hey Dave, you have done some work here, you should have pressed save but tough cookie, i am rebooting without your consent

    Hindsight is a wonderful thing

    the reality is though, yes your are bang on, should save every time I do some work...

    Thanks for your reply though

  6. #6
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Never work on something for long periods of time without at least saving, if not save as.

    Case in point -

    The devil thought he was a better coder than Jesus so he issued a challenge. They agreed that after 4 hours, God would review their work and decide who was the better code writer. The devil pounded out pages upon pages of code and could not help but observe Jesus' somewhat casual and unhurried approach. Five minutes before the final bell, the electrical power failed in Heaven and there was a blackout. The devil was beside himself with anger and despair, having lost all of his work. When God declared Jesus the winner, the devil ranted that it was not fair because of the blackout.

    God said "There is a good reason that Jesus is a better programmer than you."

    "What's that?" the devil sneered.
























    "Jesus saves." said God.

    Now you'll never forget to do the same.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    FWIW I backup my files (no serious development these days) at 18:00 and 20:00. One is to a local drive, the other to my NAS drive.
    When I was using access I used to backup via a button each day before starting work on any DB, FE or BE.

    The easier you make it, the more likely you are to use it?
    Make it cumbersome and you will only use it once in a blue moon.

    I ran CreateBackUpFE and BE from a switchboard, so they had to be functions.

    HTH

    Code:
    Option Compare Database
    Option Explicit
    Public Const strcJetDateTime = "\#mm\/dd\/yyyy\ hh:nn:ss#"  'Needed for dates in queries as Access expects USA format.
    
    
    Function GetAccessBE_PathFilename(pTableName As String) As String
    'strive4peace
    
    
       ' RETURN
       '  the file path and file name of the BE database
       '  "" if the table is not linked
       
       On Error GoTo Proc_Err
       
       Dim db As DAO.Database _
          , tdf As DAO.TableDef
       
       GetAccessBE_PathFilename = ""
       
       Set db = CurrentDb
       Set tdf = db.TableDefs(pTableName)
       
       If Len(tdf.Connect) = 0 Then
          GoTo Proc_Exit
       End If
       
       ' look at Connect string - Database Type is the first thing specified
       ' if the BE is Access
       If InStr(tdf.Connect, ";DATABASE=") <> 1 Then
          GoTo Proc_Exit
       End If
       
       GetAccessBE_PathFilename = Mid(tdf.Connect, 11)
        
    Proc_Exit:
       On Error Resume Next
       Set tdf = Nothing
       Set db = Nothing
       Exit Function
      
    Proc_Err:
       MsgBox Err.Description, , _
            "ERROR " & Err.Number _
            & "   GetAccessBE_PathFilename"
    
    
       Resume Proc_Exit
       Resume
                 
    End Function
    Sub CreateBackup(Optional strDBType As String)
        Dim strDBpath As String, ext As String, tmp As String
        Dim strPath As String, strBackupPath As String, strDB As String
        
        
        'tmp = CurrentDb.Name    'or maybe this should be the name of your BE
        'strDBType = "FE"
        strDBpath = GetAccessBE_PathFilename("tbl-version_fe_master")
        strPath = Left(strDBpath, InStrRev(strDBpath, "\"))
        strBackupPath = strPath & "Backup\"
        
        'Will now backup front and back end database
        If strDBType = "FE" Then
            strDBpath = CurrentDb.Name
        End If
        strDB = Right(strDBpath, Len(strDBpath) - InStrRev(strDBpath, "\"))
        
        With CreateObject("Scripting.FileSystemObject")
            'ext = "." & .GetExtensionName(tmp)
            tmp = strBackupPath & Format(Now(), "yyyymmdd_hhnnss") & "_" & strDB
            .CopyFile strDBpath, tmp
        End With
        MsgBox strDBType & " Database saved as " & tmp
        
        
    End Sub
    
    
    Function CreateBackupFE()
    ' Have to do it this way as Switchboard does not allow parameters.
    CreateBackup ("FE")
    End Function
    Function CreateBackupBE()
    ' Have to do it this way as Switchboard does not allow parameters.
    CreateBackup ("BE")
    End Function
    Public Function GetBackEndPath() As String
    On Error GoTo Err_Handler
        Const Attached = dbAttachedTable Or dbAttachedODBC
        Dim dbs As Database
        Dim tbl As TableDef
        Set dbs = DBEngine(0)(0)
        For Each tbl In dbs.TableDefs
            ' Gets the back end full path
            Debug.Print tbl.Name
            Debug.Print tbl.Connect
            If (tbl.Attributes And Attached) <> 0 And Left(tbl.Connect, 10) = ";DATABASE=" Then
                GetBackEndPath = Mid(tbl.Connect, 11, Len(tbl.Connect) - 10)
                Exit For
            End If
        Next
    
    
        Set dbs = Nothing
        Set tbl = Nothing
        
    Exit_Handler:
        Exit Function
    
    
    Err_Handler:
        MsgBox (Err.Number & " " & Err.Description & " " & "SelectAll()")
        Resume Exit_Handler
        
    End Function
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  8. #8
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,365
    Micron, i like it hahaha

    WGM, yes i will look into your link you sent in an earlier post on this thread and your backup function

    thanks again guy's always appreciate a prod to be sensible about my work

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

Similar Threads

  1. Replies: 2
    Last Post: 03-04-2020, 07:45 PM
  2. MS Access stored query roll back if unsuccessful
    By greatwhite in forum Queries
    Replies: 2
    Last Post: 05-30-2019, 11:23 AM
  3. Access back end file
    By CHEECO in forum Access
    Replies: 3
    Last Post: 08-02-2016, 03:26 PM
  4. Replies: 2
    Last Post: 05-01-2014, 01:31 PM
  5. Moving a back-end file
    By Ted C in forum Security
    Replies: 1
    Last Post: 08-06-2010, 12:33 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