Reputation: 29
I have a form for recording the phone numbers which have two kinds:
I want to make the ValidationRule change according to the Combobox that determines the type of phone numbers.
I tried to use ValidationRule in the form properties but it doesn't work with IIf
formula or dependening on the value of another textbox or combobox.
So I made this piece of code, but it doesn't work:
If me.combo.value = "internal" then
Me.field.validationrule = "Len([field]) = 4"
ElseIf Me.combo.value = "external" Then
Me.field.validationrule = "Len([field]) = 4 or Len([field]) = 7 or Len([field]) = 8"
End If
Thanks in advance.
Upvotes: 0
Views: 500
Reputation: 29
The code for which I ask
If me.combo.value = "enteral" then Me.field.validationrule ="Is Null OR Like """"" Elseif me.combo.value = "extetnal" then. Me.field.validationRule="Is Null OR Like """" OR Like """" OR Like """""
End if.
Upvotes: 0
Reputation: 4100
You don't have to change the validation rule. Try something like this instead:
([combo]="internal" And Len([field])=4) Or ([combo]="external" And (Len([field])=4 Or Len([field])=7 Len([field])=8))
Upvotes: 1