Results 1 to 2 of 2
Thread: Undo with VB? (Acc2000)
2003-05-21, 12:06 #1
- 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.
2003-05-21, 12:22 #2
- Join Date
- Mar 2002
- Thanked 30 Times in 30 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