• Undo with VB? (Acc2000)

    Author
    Topic
    #387858

    Is there a way to replicate with VB what the Undo toolbar button does? I would like to add the the functionality of what that button does, specifically, add some housekeeping code after the undo is used.

    Viewing 0 reply threads
    Author
    Replies
    • #678558

      The VBA instruction that closest resembles Edit | Undo, Ctrl+Z and the Undo toolbar button is RunCommand acCmdUndo. But it is not fully equivalent: the menu command etc. are being enabled and disabled as appropriate, whereas RunCommand acCmdUndo raises an error if you try to execute it in a situation where Undo is not available.

      On a form, there are are additional methods: editable controls such as a text box and combo box have an Undo method that cancel the changes to the contents of the control. You can use this in the BeforeUpdate event of the control to cancel changes if they don’t meet certain criteria. The form itself also has an Undo method that cancels all edits to the current record. You can use this in the BeforeUpdate event of the form to cancel changes.

      Example:

      Private Sub Form_BeforeUpdate(Cancel As Integer)
      If IsNull(Me.txtDateStart) Then
      Me.Undo
      End If
      End Sub

    Viewing 0 reply threads
    Reply To: Undo with VB? (Acc2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: