Data Validation With Multiple Criteria

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
 
L

Linq Adams via AccessMonster.com

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top