If statement on 5 different checkbox variables

dan231

Registered User.
Local time
Today, 13:36
Joined
Jan 8, 2008
Messages
158
I have a report that has only 1 checkbox depending on 5 different True/False fields. Is there a way to merge these into that one box? Example: if any of the 5 checkboxs are true, then the report's checkbox will also be true.

I am debating to add a new user field to the form, but this sounds redundant as the data is already checked, but it seems to be the easy and safe option. If it's check it's true and unchecked it's false and I won't be stuck with the problem below.

OR I can add code to the form that states if any checkbox is true then the new (hidden) checkbox is true.

I would need this new checkbox to stay true if any of the boxes are checked and false if they are all false. This is where I am stuck - I don't know how to write that part.

I can add the following to each of the 5 boxes, but then I'm stuck:
Code:
Private Sub chkBox1_Click()
    If chkBox1.Value = True Then
        chkBoxNew.Value = True
    End If
End Sub
Am I on the wrong track here with this second option? I am only entertaining this as it seems easier for the end user.
 
The "chkBoxNew" control should be unbound and the value never stored, only calculated as needed.

For the control chkBoxNew try setting the control source to:


=(Nz(chkBox1,0) or Nz(chkBox2,0) or Nz(chkBox3, 0) or Nz(chkBox4,0) or Nz(chkBox5,0) )
 
If it's not stored, should I have this control on the actual report then?
 
I would only calculate the value in an unbound Checkbox when you want to display it. If you only need to see it on a report, then that is the only place I would do it. If you are not displaying on the form, I see no need to add the extra "weight" to the form it it will not bee seen.
 
That works great! Thank you for your help.
 

Users who are viewing this thread

Back
Top Bottom