Results 1 to 5 of 5
  1. #1
    mcaliebe is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Jun 2017
    Posts
    18

    Update Changes to Record before Record Changes

    On my form, I have a command to edit data, save data, and cancel changes and these all work well. I want to include a message if the current record is dirty and the user uses changes the record without saving changes. I tried setting the following code in the forms current even, but it doesn't seem to check if the current record is dirty. It appears to look at the condition of the next record, however if I check for Dirty with my Cancel Changes command, it recognizes the form is dirty.

    Any Thoughts?



    Code:
    If Me.Dirty = True Then
        response = MsgBox("Change Record and Discard Changes?", vbYesNo)
            If response = vbYes Then
            DoCmd.RunCommand acCmdUndo
            Else
            Exit Sub
            End If
    End If

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Try using the BeforeUpdate event instead.

  3. #3
    mcaliebe is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Jun 2017
    Posts
    18
    This works well to check if the user made changes. I am testing for Me.Dirty and if the form is, the warning fires off. However, even after the record is saved and updated, the form still shows as Dirty so when moving onto the next record, the warning fires again. How do I bypass this check after a recent save, or how do I have a clean form after a save?

  4. #4
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Me.Dirty=False

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    For the record: the BeforeUpdate event *only* fires when the Form is Dirty!

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

Similar Threads

  1. Replies: 16
    Last Post: 01-18-2016, 07:25 PM
  2. Replies: 3
    Last Post: 10-04-2015, 10:17 AM
  3. Replies: 4
    Last Post: 02-18-2015, 11:28 AM
  4. Replies: 1
    Last Post: 05-26-2014, 12:39 PM
  5. Replies: 4
    Last Post: 12-14-2012, 06: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