Results 1 to 2 of 2
  1. #1
    Star Lounger
    Join Date
    Sep 2001
    Pleasanton, California, USA
    Thanked 0 Times in 0 Posts

    Undo with VB? (Acc2000)

    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.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 28 Times in 28 Posts

    Re: Undo with VB? (Acc2000)

    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.


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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts