Monday, September 26, 2005

How to undo whole record

This tip I learned from MVP Allen Browne
Here a code, which you can place into Undo button click event:

If Me.Dirty Then
Me.Undo
End If
If Not Me.NewRecord Then
RunCommand acCmdDeleteRecord
End If

8 comments:

  1. Anonymous5:56 PM

    Very useful, thanks. I was strugling with undo on a form with both bound and unbound controls and couldn't get the "DoCmd" to work properly. But this code does the trick.

    ReplyDelete
  2. Anonymous12:51 PM

    i was wondering if we can bypass the prompt for deletion

    i mean, if there was no prompt before deleting the record, the undo operation would have looked more realistic :)

    any thoughts?

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Hi,
    you can switch off delete prompts in access options

    ReplyDelete
  5. Anonymous7:39 PM

    ya that works :)

    tools > options > Edit/Find > Confirm (Uncheck Record Changes option)


    thanks for your "prompt" reply :)

    ReplyDelete
  6. Anonymous4:54 PM

    Or you could put in VBA:

    DoCmd.SetWarnings (False)
    ...here comes your 'undo' code
    DoCmd.SetWarnings (True)

    _ _ _ _ _ _ _ _ _ _ _ _
    this way you would have the warnings only temporarly inactive.

    ReplyDelete
  7. Anonymous5:59 PM

    Amazing!

    ReplyDelete
  8. Anonymous11:17 AM

    Anyone who knows where I can find a solution for this for Access 2010 Web (Macro style)?

    ReplyDelete