Conditional formatting of checkbox?

C

CW

In Access 2003, is conditional formatting possible on a Y/N checkbox?
I have a fairly important checkbox that I would like to highlight in red if
checked, to grab the user's attention.
If it's not possible, any suggestions for other ways of doing this??
Many thanks
CW
 
F

fredg

In Access 2003, is conditional formatting possible on a Y/N checkbox?
I have a fairly important checkbox that I would like to highlight in red if
checked, to grab the user's attention.
If it's not possible, any suggestions for other ways of doing this??
Many thanks
CW

Check boxes are graphic images and are not resizable nor color
changeable.
What you can do is change the color of the check box label using code,
if you are using Single Form view.
Code the Check Box AfterUpdate event:
If Me.CheckBoxName = True then
Me.CheckLabelName.BackColor = vbRed
Me.CheckBoxLabel.ForeColor = vbYellow
Else
Me.CheckLabelName.BackColor = vbWhite
Me.CheckBoxLabel.ForeColor = vbBlack
End If

*** Place the same code in the form's Current event. ***

or .... you could place a rectangle around the check box, Send it to
Back, and change it's backcolor using similar code to the above.
 
W

Wayne-I-M

Or you could make a small text box and set the font to windings2 (P will give
you a tick).
 
C

CW

Thanks Fred, that looks good and I can see myself using that or similar code
in a number of other scenarios
CW
 
K

Ken Sheridan

Wayne's suggestion is the way to do it, but you need to do a little work:

1. Add the real checkbox, bound to the Boolean field in the table, to the
form and set its Visible property to false.

2. Add a text box sized to mimic a check box and set its FontName property
to Wingdings and its ControlSource property to:

=IIf([chkMyBooleanField],Chr(252),"")

where chkMyBooleanField is the name of the hidden real check box.

3. Use condtional formatting to set the colours of the text box as required
on the basis of Expresssion Is [chkMyBooleanField].

4. Add a button over the text box and set its Transparent property to True,
and for its Click event procedure use the following code:

Me!chkMyBooleanField = Not Me!chkMyBooleanField

When the user clicks the pseudo check box text box they will actually click
the button, which will set the value of the hidden real check box, and hence
the Boolean column it is bound to. The expression used as the text box's
ControlSource property will show it checked or unchecked and the conditional
formatting will change its colours.

PCW magazine did publish a form of mine showing how this is done, along with
other formats for pseudo check boxes, but I don't imagine its on their site
now. If you want a copy mail me at:

kenwsheridan<at>yahoo<dot>co<dot>uk

Ken Sheridan
Stafford, England
 
C

CW

Ken - that's rather sneaky, and very creative. I will definitely give it a try.
Thanks
CW

Ken Sheridan said:
Wayne's suggestion is the way to do it, but you need to do a little work:

1. Add the real checkbox, bound to the Boolean field in the table, to the
form and set its Visible property to false.

2. Add a text box sized to mimic a check box and set its FontName property
to Wingdings and its ControlSource property to:

=IIf([chkMyBooleanField],Chr(252),"")

where chkMyBooleanField is the name of the hidden real check box.

3. Use condtional formatting to set the colours of the text box as required
on the basis of Expresssion Is [chkMyBooleanField].

4. Add a button over the text box and set its Transparent property to True,
and for its Click event procedure use the following code:

Me!chkMyBooleanField = Not Me!chkMyBooleanField

When the user clicks the pseudo check box text box they will actually click
the button, which will set the value of the hidden real check box, and hence
the Boolean column it is bound to. The expression used as the text box's
ControlSource property will show it checked or unchecked and the conditional
formatting will change its colours.

PCW magazine did publish a form of mine showing how this is done, along with
other formats for pseudo check boxes, but I don't imagine its on their site
now. If you want a copy mail me at:

kenwsheridan<at>yahoo<dot>co<dot>uk

Ken Sheridan
Stafford, England

CW said:
Thanks Wayne
CW
 

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

Similar Threads


Top