How can I create a conditional validation rule in Access

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a combo Box with four values (1,2,3,4). I want a validation rule that
when I choose a value from the combo box to permit me to enter a range of
values into a text box. Meaning if I choose from combo box the value "1", in
the text box to permit me to write any number from 1 to 10. If I choose from
combo box the value "2" then in the text box to permit me to write any number
from 11 to 20 and so on.
I think it sould go something like this:
"=IIf(([cmbCC].[Column](0))=1,[txtExactCylinderCapacity] Between 10 And 20,6)"
Thanks in advance
 
"Excise" wrote:
You can do this with the Before Update event of the Text Box:

Dim intLow as Integer
Dim intHigh as Integer

Select Case Me.ComboBox
Case Is 1
intLow = 1
intHigh = 10
Case Is 2
intLow = 11
intHigh = 20
Case Is 3
intLow = 21
intHigh = 30
Case Is 4
intLow = 31
intHigh = 40
Case Else
intLow = -1
End Select

If intLow = -1 Then
MsgBox "No Value Entered in Combo Box"
Cancel = True
Else
If Me.TextBox < intLow Or Me.TextBox > intHigh Then
MsgBox "Value Entered Must Be Between " & intLow & " And " &
intHigh
Cancel = True
End If
End If
 

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

Back
Top