Check Boxes

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

Guest

Is it possible to edit the colour of the check box label text so that if the
check is true the label text changes colour?
Then if the check box is changed back to false the label text changes back
to its original colour?

Also I have a form that has a large number of check boxes and I would like
to know how to count the number of check boxes that are true.

All help is appreciated

Nick
 
Is it possible to edit the colour of the check box label text so that if the
check is true the label text changes colour?
Then if the check box is changed back to false the label text changes back
to its original colour?

Also I have a form that has a large number of check boxes and I would like
to know how to count the number of check boxes that are true.

All help is appreciated

Nick

The Form is in Single Form view?
To change the backcolor/forecolor of the label dependent upon the
value of a check box, code the check box AfterUpdate event:

If Me!CheckBoxName = -1 Then
Me!LabelName.BackColor = vbBlue
Me!LabelName.ForeColor = vbYellow
Else
Me!LabelName.BackColor = vbWhite
Me!LabelName.ForeColor = vbBlack

End If

Place the same code in the form's Current event.
 
Hi Fred,
Thanks for your reply.
My problem is that the form is a sub-form, with 168 checkboxes, on a page of
a tab control. When I use the code you suggested it works well but if I go to
another record and then return back to the original record it has changed
back to the original colours.
I tried to do as you said, putting the code it the forms on current property
but as I have so many checkboxes I can’t get it to work.

I would appreciate it if you can suggest what else I can try.

Regards
Nick
 
Thanks,
I have entered the code in the forms on current event at the lowest level
form and it works for the first checkbox. As I am using 168 checkboxes, so do
I need to repete this code for each checkbox or is it possible to use code
that covers all checkboxes?

Nick
 
One way or another, since every checkbox can have a different value,
each has to be checked separately. Every one will have to have the test
made.

However that can be done by writing out the code for each and every box

OR
by creating a subroutine that perhaps has the name or perhaps the
control item # passed to it and that subroutine called for each box.
But even then that sub-routine will have to be called for each and
every box and./ or be executed via an more elaborate subroutine called
on the on current event of the form (along with the after update event
for each of the boxes.)

Depending on how you have your 168 boxes arranged, you may want to set
up a different set of colors for every 10 or so of your boxes. Looking
at 168 checkboxes will most probably lead to a cross-eyed operator
after a while, trying to figure out where they are on the screen/form.
Or you might try a different color for every 10 or so and change to
bold or not if it is checked - although bolded text takes up more space
on the screen.)
 
Back
Top