CreganTur
06-06-2008, 07:45 AM
Okay, I'm validating text entered into a textbox using the After update event. I want to check and see if the value entered is not a certain value, and throw a message if the entered value is not one of the prescribed values in the expression.
Problem is that it's not working correctly. It will throw the error message no matter what.
Here's some example code:
Private Sub txtField_AfterUpdate()
If Not Me.txtField = 1 Or 2 Or 3 Then
MsgBox "Invalid Entry"
End If
End Sub
As you can see, my intention is that if the user updates the textbox with anything other than 1, 2, or 3, then the MsgBox should show. But it's showing even if I enter 1, 2, or 3:banghead:
I've attached a sample database that puts all of this into practice. I'm hoping someone can tell me why it's not working!
Problem is that it's not working correctly. It will throw the error message no matter what.
Here's some example code:
Private Sub txtField_AfterUpdate()
If Not Me.txtField = 1 Or 2 Or 3 Then
MsgBox "Invalid Entry"
End If
End Sub
As you can see, my intention is that if the user updates the textbox with anything other than 1, 2, or 3, then the MsgBox should show. But it's showing even if I enter 1, 2, or 3:banghead:
I've attached a sample database that puts all of this into practice. I'm hoping someone can tell me why it's not working!