change color for check box

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

Guest

I have created a check box on my form and I want to know if there's a code
that I can use to change the background color of the label once the box is
checked. Thanks.
 
Yes - you can't change the Backcolor of the checkbox itself, as
checkboxes don't support this property - but you can change the
Backcolor of the label.

Select the label by clicking on it (NB if you click on the checkbox,
the label will also be "selected" as a linked label, but you won't be
able to edit the label's properties). View menu/Properties. Give the
label a sensible name (e.g. Lbl_Chksomething, rather than "LAbel185").

The event that will run when the checkbox changes is the AfterUpdate
event. You could use BeforeUpdate, but there's no reason to in this
situation.

In the AfterUpdate event procedure, test whether the checkbox is True
(=checked), and if so change the label's backcolor:

If Me.[name of checkbox].Value=True Then
Me.[name of label].Backcolor=[a colour number]
Else
'Change the colour back if checkbox is "unchecked"
Me.[name of label].BackColor=[another colour number]
End If

to get the colour numbers, mess about with the label's Backcolor in its
Properties pane: choose your colour, and see what number it comes up
with in the property box.

cheers


Seb
 
put that code in both the afterupdate for the field
AND
the oncurrent event for the form....
 

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

Back
Top