Expression in validation rule

G

Guest

How do you implement the following expression as a validation rule for a
checkbox on a subform of parent form 'Form_Par'? Given: Field_H is a
checkbox control.

IIf([Forms]![Form_Par].[Field_H]="Yes","Yes","Yes" or "No")
 
A

Al Campagna

Jay,
I'm not sure what the IIF wants to return if Field_H = False. "Yes" or "No" is not a
legitimate return value for the IIF statement.
Assuming "Yes" or "No" returned accordingly.... and H being Boolean... and also
assuming the IIF is in a subform...

IIF(Forms!Form_Par!Field_H = True, "Yes", 'No")

If H =True the field will display text "Yes", otherwise "No"
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."
 
M

Marshall Barton

Jay said:
How do you implement the following expression as a validation rule for a
checkbox on a subform of parent form 'Form_Par'? Given: Field_H is a
checkbox control.

IIf([Forms]![Form_Par].[Field_H]="Yes","Yes","Yes" or "No")

Acheck box value is either True or False, not the strings
"Yes" or "No".

I think you might get an acceptable validation rule out of
this kind of partial expression:

=([Forms]![Form_Par].[Field_H] = True) Or (Not
[Forms]![Form_Par].[Field_H])
 
G

Guest

Hi Al -

Thanks for the response and I'm sorry for the slow reply.

Your comments put me right back on track. My original post used string
values ("Yes" and "No") inapproriately as you noted. Checkboxes evaluate to
Yes/No, True/False, On/Off, or -1/0. That reminder helped solve my problem.

Also, using the conditional formula was unnecessary. All that is needed in
a validation rule is an expression that evaluates to True (as you suggested);
if the expression is True, then an entry can be made (in this case the
checkbox could be checked). If the expression evaluates to False, the
checkbox cannot be changed.

Here is the expression that worked as the validation rule for the field on
the subform of parent form Form_Par:

[Forms]![Form_Par].[Field_H]=No


So, if Field_H was unchecked (=No), then the above evaluates to True (the
validation rule is satisfied) and the subform checkbox becomes "check-able."

Thanks a bunch for the leads.
--
Jay


Al Campagna said:
Jay,
I'm not sure what the IIF wants to return if Field_H = False. "Yes" or "No" is not a
legitimate return value for the IIF statement.
Assuming "Yes" or "No" returned accordingly.... and H being Boolean... and also
assuming the IIF is in a subform...

IIF(Forms!Form_Par!Field_H = True, "Yes", 'No")

If H =True the field will display text "Yes", otherwise "No"
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."


Jay said:
How do you implement the following expression as a validation rule for a
checkbox on a subform of parent form 'Form_Par'? Given: Field_H is a
checkbox control.

IIf([Forms]![Form_Par].[Field_H]="Yes","Yes","Yes" or "No")
 
G

Guest

Thanks to you, too, Marshall. Your syntax is also corrective for my original
problem. In essence, checkboxes don't evaluate to "Yes" or "No" strings.
What was I even thinking ?

Thanks again,
--
Jay


Marshall Barton said:
Jay said:
How do you implement the following expression as a validation rule for a
checkbox on a subform of parent form 'Form_Par'? Given: Field_H is a
checkbox control.

IIf([Forms]![Form_Par].[Field_H]="Yes","Yes","Yes" or "No")

Acheck box value is either True or False, not the strings
"Yes" or "No".

I think you might get an acceptable validation rule out of
this kind of partial expression:

=([Forms]![Form_Par].[Field_H] = True) Or (Not
[Forms]![Form_Par].[Field_H])
 

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