The Undo method applies to a control object or a form object. It reset
the object.
When validating data, as you are doing, you can use it in the controls
Before Update event. The Before Update event has a Cancel argument
that when set to True will cancel the update and keep the focus on the
control.
To put what I posted earlier in this context it would be something
like...
Private Sub txtBox_BeforeUpdate(Cancel As Integer)
If Me.txtBox = "foo" Then
MsgBox "No Foos allowed."
Me.txtBox.Undo
Cancel = True
End If
End Sub
For use in a form you might use Me.Undo in the Form's Before Update
event to reset the entire form.
- Jim
On Wed, 31 Dec 2003 21:53:15 GMT, "deko" <dj****@hotmail.com> wrote:
Do a google newgroups search on the subject for more information.
I did come across some warnings about SendKeys and possible bugs in older
versions of Access.
There is a huge difference. You are best to avoid SendKeys. It should
only be used in *very* limited circumstances.
I'm all for sticking to best practices...
See below for how I'm using the Undo event - but I'm confused about a few
things. any enlightenment is appreciated...
what does "Cancel = True" do? - I tried this but it would not compile. -
just Me.Undo seems to be working okay...
what does "DoCmd CancelEvent" do?
how do I use the "On Undo" field in a form's property sheet?
Private Sub Whatever ()
[code omitted...]
Exit_Here:
Exit Sub
HandleErr:
Select Case Err.Number
Case 3022
Me.Undo
Resume Exit_Here
Case 94
Resume Next
Case Else
modHandler.LogErr (Me.Form.Name)
Resume Exit_Here
End Select
End Sub