Hi,
In the BeforeUpdate event of a textbox control I have the following
simplified code:-
Private Sub StartDate_BeforeUpdate(Cancel As Integer)
[some validation code -- the following code is executed if validation
fails]
MsgBox "StartDate Error -- Please Check and Re-Enter."
Me!StartDate.Undo
Debug.Print "After Undo: " & Me!StartDate
Cancel = True
[Code to reset some other stuff based on the "undone" StartDate]
GoTo ProcEnd
[...]
ProcEnd:
End Sub
When an error occurs, the original textbox value is restored at the end of
the Before Update event by the "Cancel = True" statement. The
"Me!StartDate.Undo" statement does nothing. The Debug.Print still shows the
invalid value.
The online Help for .Undo recommends using this method in the control's
Change event. Is this the only place it can be used for a control? Does it
not work in the BeforeUpdate event? Or am I coding it incorrectly?
The problem is that when the data is found to be invalid, I need to reset
some other fields based on the original value of the text box before leaving
the BeforeUpdate event. If .Undo does not work in this context, maybe I
should be trying .OldValue instead of the Undo method as the basis for
resetting the other stuff?
Any guidance appreciated.
--
Cheers,
Lyn.