Results 1 to 7 of 7
  1. #1
    Foyer is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2021
    Posts
    12

    Can you go back (revert) to previous 'saves' in Access?

    A couple weeks ago I was chatting with someone who mentioned that in newer releases you had the ability to revert back to previous saves, which is handy if you have an oops moment.



    Well, I did just make an oops that removed my last probably 2 hours of work, and I'm wondering if this is true, and if so, how do you find those previous iterations?

    Probably not true, but figured it was worth an ask.

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    All been there, but the ability has been around for years - it's called a backup. Before you open an app to make changes it is good practice to make a copy and use versioning. Typically I might have 40 or 50 versions of an app before it is ready to be released to production.

    providing you haven't closed the app, you can use ctrl-z or undo to recover accidentally deleted or modified vba code or deleted objects

    not aware of anything that tracks design changes

  3. #3
    Foyer is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2021
    Posts
    12
    Thank you, Ajax. I thought it might be a pipe dream.

    And I got lucky. I deleted a piece of VBA code but a lingering End Sub ended up in the Option Compare Database section and forked everything. Simple fix once I realized it.

    Versioning is so easy I don't know why I'm stubborn about it. Especially since I'm such a newb and every basic task takes an immense amount of effort.

    I only start a new version when I start working on a new table or form, etc., and not when I switch gears within those parameters. I need to do better.

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    Something else you can do is log details of your activity - outline of what you are planning to change, over view of changes made, a date and I include a code reference. I store all in a vba module all commented out and place the code reference in each sub/function affected along with more detailed info if required so easy to find when changes are more complex where they all occurred and you can ‘link’ across modules

    I tried doing this in a table but found it easier in a module as you are still in the same environment.

    Changes to forms, report and query design can still be noted in the same place and I also tend to take a copy before starting and name the copy with a zz prefix and an enumerator suffix

  5. #5
    Foyer is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2021
    Posts
    12
    That's a brilliant idea. I was trying to find places where I could jot notes in the actual database. I've got some comments in the VBA if it's directly related to that code (and I've jotted fixes and stuff on forms as reminders), but I really wanted to be able to comment on other aspects of the database and couldn't find a good place to do it.

  6. #6
    Join Date
    Apr 2017
    Posts
    1,776
    Quote Originally Posted by Foyer View Post
    A couple weeks ago I was chatting with someone who mentioned that in newer releases you had the ability to revert back to previous saves, which is handy if you have an oops moment.
    Probably I stumbled into this feature yesterday. It isn't about reverting back to previous design - when you open the database and manipulate data there, and something happens with database, the database closes with message about saving to backup file. After that, depending your choice, the database closes with or without saving it to backup file of app's choosing. When saving, you can't overwrite any existing file. Your old database/frontend file remains as it was before you opened earlier. I didn't check out jet, how do saved backup files differ compared with original one - was too busy for this then, and now the issue is corrected (as the backup is from front-end only, I don't think there were any differences). But I think I did change some data before the app crashed(but I'm not sure about this!), and those changes were missing in SQL Server back-end after the app crashed (the difficulty is, that the front-end has some own tables where temporary data are saved, and those are are written into back-end tables when a procedure is run - and I don't remember anymore, at which moment the crash occurred),

  7. #7
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    213
    Won't help you now, but it may prevent some future catastrophe...

    I use a bit of code in most of my databases that automatically creates a backup copy of the entire db on startup. Put it in the Open or Load event of the first form, or maybe even in the ribbon's Load event, if you use a custom ribbon.

    It makes a backup copy on every start if the last backup was more than one hour ago. It tests for me as the logged in user, so it doesn't do this for users once it's deployed, and the one-hour gap is to keep from making too many copies when I may be opening and closing several times per minute during tests of some initialization code.

    It's much safer than trying to remember to make backups manually, especially since crashes tend to happen right when you slack off the manual backups because everything has been running well. It also helps when you make some changes in code and later realize that you want something after all. Instead of having to re-create it, you can just look in a backup from before the change.

    At some point, you need to purge the backup copies, since they accumulate, but that is a small price to pay. The backups go into a special sub-folder in the development folder, and the names are time-stamped. The code here is from a database named DataSavcu and the last saved date is stored in a custom document variable named LastDevBackup - edit to taste.

    Code:
    If gbl_User Like "*danes*" Then    If Not fs.folderexists(CurrentProject.Path & "\DevBackup\") Then fs.Createfolder CurrentProject.Path & "\DevBackup\"
        If Format$(DateAdd("h", -1, Now), "YYYY-MM-DD HH:NN") > ReadCustomDocumentProperty("LastDevBackup") Then
            fs.CopyFile CurrentProject.Path & "\DataSavcu.accdb", CurrentProject.Path & "\DevBackup\DataSavcuDevBackup_" & Format$(Now(), "yyyy-mm-dd_hh-nn-ss") & ".accdb"
            WriteCustomDocumentProperty "LastDevBackup", Format$(Now, "YYYY-MM-DD HH:NN")
        End If
    End If
    Support functions:

    Code:
    Public Sub WriteCustomDocumentProperty(ByVal PropertyName$, ByVal PropertyValue As Variant)
    ' Custom doc variable must contain at least one character, or Access removes it.
    If PropertyValue = "" Then PropertyValue = " "
    CurrentDb.Containers(1).Documents("UserDefined").Properties(PropertyName) = PropertyValue
    End Sub
    
    
    Public Function ReadCustomDocumentProperty(ByVal PropertyName$) As Variant
    ReadCustomDocumentProperty = CurrentDb.Containers(1).Documents("UserDefined").Properties(PropertyName)
    If VarType(ReadCustomDocumentProperty) = vbString Then ReadCustomDocumentProperty = Trim$(ReadCustomDocumentProperty)
    End Function

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

Similar Threads

  1. Replies: 3
    Last Post: 04-09-2020, 11:48 AM
  2. Replies: 11
    Last Post: 11-07-2017, 04:43 AM
  3. Replies: 2
    Last Post: 09-17-2015, 12:38 PM
  4. Replies: 7
    Last Post: 02-08-2014, 12:31 PM
  5. How do I go back to previous weekday?
    By bigspace55 in forum Queries
    Replies: 2
    Last Post: 01-29-2013, 10:56 AM

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