Data Validation With Multiple Criteria

  • Thread starter Thread starter Korski
  • Start date Start date
K

Korski

I currently have a form that accepts sample measurements. Is there a way to
place multiple validation rules into a text box so that there is either a
measurement entered between 4" and 4.5" or the text box is left empty
as the other choice. (This last option would be to allow a person who
accidentally entered a measurement into the wrong text box to go back and
delete it without breaking the validation rule )

I'd greatly appreciate any advice on the best way to do this, Thanks, Adam
 
Private Sub YourTextBox_BeforeUpdate(Cancel As Integer)
If Not IsNull(Me.YourTextBox) Then
If Me.YourTextBox < 4 Or Me.YourTextBox > 4.5 Then
MsgBox "Measurement must be between 4.0 and 4.5"
Cancel = True
Me.YourTextBox.SelStart = 0
Me.YourTextBox.SelYour = Len(Me.YourTextBox)
End If
End If
End Sub

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
 
Back
Top