ericmurphy Posted September 17, 2008 Posted September 17, 2008 Is there a way to make a field conditionally required? For example, can you make field A required to be "not empty" only if field B has a value, but not required to be not empty if field B does not have a value?
Josh Ormond Posted September 17, 2008 Posted September 17, 2008 In the validation options, you can validate by calculation. It uses a Boolean expression (True/False).
ericmurphy Posted September 17, 2008 Author Posted September 17, 2008 Forgive my ignorance, but how does this actually work? I have a group of address fields, (street, city, state, etc.) that I want to be required if the value of the field "Different contact Info?" equals "Yes" If the value of that field is "No" (or any other value), I want the address fields to not be required. I tried checking the "validate by calculation" and then creating a calculation where "Different Contact Info? = "Yes" but that didn't make the field required to have a value even if "Different Contact Info" = "Yes"
Raybaudi Posted September 17, 2008 Posted September 17, 2008 Try this calc into validation option of field address: Case( Different contact Info? = "YES" and IsEmpty ( Self ) ; 0; 1 ) Remember to uncheck the box: Validate only if field has been modified
Fitch Posted September 17, 2008 Posted September 17, 2008 Try this (using "address" field for example): Case( Different Contact Info = "Yes" ; not IsEmpty( address ) ; 1 )
ericmurphy Posted September 17, 2008 Author Posted September 17, 2008 I tried that, but still no luck. The only thing that changes whether the field is required or not is if the "Not Empty" checkbox is toggled, regardless of whether "Validated by Calculation" is checked or not.
Raybaudi Posted September 17, 2008 Posted September 17, 2008 Try again. Different contact Info? may have 3 status: 1) Empty 2) some chars 3) YES but only when in status 3) we want Address NOT empty So the expression: Different contact Info? = "YES" and IsEmpty ( Self ) must produce an error. Any other must be accepted.
ericmurphy Posted September 17, 2008 Author Posted September 17, 2008 There's a saying, "trying the same thing over and over and expecting different results amounts to insanity." So I would have to change something in order to make it worth trying. Any suggestions? It would help if I were a bit clearer on what the "Validate by calculation" really means. What I want it to mean is, "this field cannot be empty if this other field has a value of 'yes'." Is there a programmatic way of achieving this end?
Raybaudi Posted September 17, 2008 Posted September 17, 2008 "this field cannot be empty if this other field has a value of 'yes'." [color:red]IF IsEmpty ( Self ) and Different contact Info? = "YES" [color:red]ERROR "Is there a programmatic way of achieving this end?" Yes. BTW: my calc can even be simpler: not ( IsEmpty ( Self ) and Different contact Info? = "YES" ) that is the same as saying: I don't want [color:red]( not ) this field empty [color:red]( IsEmpty ( Self ) ) when [color:red]( and ) Different contact Info? contains [color:red]( = ) "Yes"
Josh Ormond Posted September 17, 2008 Posted September 17, 2008 Obviously trying the same thing isn't going to work... You need to change something...it works fine for me. At the bottom of the calculation screen it tells you what represents True/False. "Non-zero results are true, Zero and empty results are false". If the result of the calculation is true, it accepts the value. Otherwise, it rejects the value and throws an error. If your calculation isn't resulting in the correct value, it is something in the calc.
ericmurphy Posted September 17, 2008 Author Posted September 17, 2008 Perfect, Danielle! Aside from giving me a workable solution, your example explained exactly how I could get this to work. I really appreciate your help. -e
Recommended Posts
This topic is 5970 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now