logical OR of values in a subform

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

Guest

Hi,
I would like to "Logical OR" several Yes/No values in a subform, and then
based on the result, set a Yes/No value in a main form. I would appreciate
a snipit of code if anyone has some available...

The general flow would be

IF (subform.a1 = yes, OR subform.a2 = yes, OR subform.m1 = yes,
Then set mainform.rptflag = yes)

I have "Inherited" this db and would like to make as few modifications as
possible. Any additional suggestions on how to accomplish this will be
greatly appreciated.

Thanks, Regards,
Gary
 
gary,
in this case you may need to put the following code on change events in
all checkboxes (a1,a2, m1)

if me.a1.value or me.a2.value or me.m1.value then
me.parent.rptflag.value = yes
else
me.parent.rptflag.value = no
end if
 
Gary,
Disregard Jeff's post. That is not necessary. Here a a technigue that will
do what you want. The Abs() function removes the sign bit and returns 1 for
True and 0 for false; therefore, if any boolean field is true, then you will
get a value greater than 0. If all boolean fields are false, you will get 0.
also, note I removed "set" from your code. Set is for object references.
In this case, you are assigning a value.

IF abs(subform.a1) + abs(subform.a2) + abs(subform.m1) = 0 Then
mainform.rptflag = False
Else
mainform.rptflag = True
Endif
 
Back
Top