
Originally Posted by
John_G
Hi -
Since your code is in the Before_Update event, you must also cancel the event with Cancel = -1 as well as using me.undo.
Note that me.undo resets the whole form, not just the field with the error - is that really what you want?
John
Okay, I think I've learned my lesson regarding the limitations of a control's Before UpDate event. I entered the following code in the After UpDate event of the second text box and it works:
Code:
If Me.tumorDim2 > Me.tumorDimLargest Then
MsgBox "Tumors dimensions must be entered from largest to smallest" & vbCrLf & "Please enter the tumor dimensions in the correct order.", _
vbInformation, "Data Validation Check Failed."
Me.tumorDim2.Value = ""
Me.tumorDimLargest.SetFocus
End If
Only the text box that is in error is reset as opposed to resetting the whole form with Me.undo in the Before update event. Also, the Set Focus method works. I'm not sure if Me.tumorDim2.Value="" is the right way to undo the erroneous entry but it seems to work.