G
Guest
Example
1. User is restricted by BeforeUpdate to entering number from 1-4 in text box.
(This is simplified and could really involve a database lookup.)
2. Form has a Cancel button and of course the red-X intends to close the form
3. User enters a 5 and gets MsgBox and is locked into the text box
4. User leaves 5 in text box and wants to immediately Cancel (close the form)
Is there a technique where the user could hit the Cancel button and get out
of the form even though the BeforeUpdate keeps wanting to fire before the
Cancel button can be recognized?
Or is this form behavior that just has to be lived with?
Example code for text box is:
Private Sub Text2_BeforeUpdate(Cancel As Integer)
If IsNumeric(Text2) = False Then
MsgBox "Enter a number from 1 to 4"
Cancel = True
ElseIf CDbl(Text2) < 1 Or CDbl(Text2) > 4 Then
MsgBox "Enter a number from 1 to 4"
Cancel = True
End If
End Sub
1. User is restricted by BeforeUpdate to entering number from 1-4 in text box.
(This is simplified and could really involve a database lookup.)
2. Form has a Cancel button and of course the red-X intends to close the form
3. User enters a 5 and gets MsgBox and is locked into the text box
4. User leaves 5 in text box and wants to immediately Cancel (close the form)
Is there a technique where the user could hit the Cancel button and get out
of the form even though the BeforeUpdate keeps wanting to fire before the
Cancel button can be recognized?
Or is this form behavior that just has to be lived with?
Example code for text box is:
Private Sub Text2_BeforeUpdate(Cancel As Integer)
If IsNumeric(Text2) = False Then
MsgBox "Enter a number from 1 to 4"
Cancel = True
ElseIf CDbl(Text2) < 1 Or CDbl(Text2) > 4 Then
MsgBox "Enter a number from 1 to 4"
Cancel = True
End If
End Sub