Can conditional formatting be applied to checkboxes?

M

MariahJ

I want to enable/disable a checkbox on a continuous subform based on
the result of another checkbox, but I don't want the checkboxes all of
the records to be enabled/disabled. The only way I can think of to do
this would be with conditional formatting. Can I programmatically apply
conditional formatting to a checkbox?

Thanks.
 
K

Ken Sheridan

If you set a control's Enabled property to False and its Locked property to
True then the appearance of the control will be unaltered, i.e. not greyed
out, but the user will not be able to edit it, or even move focus to it. So,
say you want a second bound check box to be inaccessible to the user if a
first one is True (checked) the add this function to the subform's (i.e. the
subform's underlying form object's) module:

Function LockControls()

Me.chkField2.Enabled = Not Me.chkField1
Me.chkField2.Locked = Me.chkField1

End Function

and set both the subform's Current event property and chkField1's
AfterUpdate event property to the following in the properties sheet:

= LockControls()

The one slight drawback of this would be that if a user checks the first
check box in one record then moves to a new (or indeed any other record)
record by clicking on the second check box the form's Current event won't
fire until after the click. This would mean that the second check box is
still inaccessible at the time of the first click, so the user would have to
click it again to check it. Focus would in fact be moved to the first
control in the form's tab order in this case as by clicking on the
inaccessible check box the user is actually just moving focus to the record,
not to the check box per se.

Ken Sheridan
Stafford, England
 
M

MariahJ

That worked! Thanks!

I will try to play with changing the background color to see if I can
create the appearance of the field being disabled, but what you gave me
does the most important part, which is to prevent the user from
checking the box.
 
K

Ken Sheridan

Check boxes don't support conditional formatting AFAIK so I think you'd have
to simulate one by using a text box and the Wingdings font. As it happens I
produced a small demo of how to create pseudo check boxes which can be sized
and formatted for a magazine article some years back. I've dug it up and
amended it to do something along the lines you want, and I'll email it to you
at the address in your profile.

If it doesn't arrive today mail me at:

ken<dot>sheridan<at>dsl<dot>pipex<dot>com

Ken Sheridan
Stafford, England
 

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

Top