Conditional Formatting for Checkbox

Reese

Registered User.
Local time
Today, 12:35
Joined
Jan 13, 2013
Messages
387
I have a continuous form that has several checkboxes in it. Only one is initially enabled and I want the first to impact if the others are enabled, but only in the currently selected record.

I tried VBA but quickly found that this enables/disables the checkboxes in ALL of the records. Next I found out about conditional formatting--which does exactly what I want, but only works on text boxes and combo lists.

Is there any way that conditional formatting can be used to impact (vs. be impacted by) a checkbox? If not, is there another way to do this?
 
rather than using a checkbox, use a textbox as follows:

1. hide your checkbox - if you are using a datasheet then you can move it to the form header
2. create a textbox 1 character wide and in the controlsoruce put
Code:
=iif([mychkbox]=true,"Y","N")
3. in the textbox on click event put me.mychkbox=not me.mychkbox

If you want to introduce some colour then in your conditional formatting you can set the backcolor to green for true and red for false - or use other characters other than Y or N in the controlsource above

Either way, you can now conditionally format your textboxes
 
Did you mean to use a textbox instead of the first checkbox, or use textboxes for the following checkboxes?

Also, will this technique set the backend values in the table as "-1" / "0"? Checkboxes associated with these same fields are already in use in other forms, so I want to keep the values consistent.

If this gets too complicated, I'll just leave all of the checkboxes enabled. It's not a huge deal, and it's rather obvious that if the "Reimbursement Needed" checkbox is unchecked then the "Reimbursement Sent" checkbox should be left alone.
 
Did you mean to use a textbox instead of the first checkbox, or use textboxes for the following checkboxes?
for consistency I was thinking you would do all checkboxes. As a minimum I would do those that you want to disable

Also, will this technique set the backend values in the table as "-1" / "0"? Checkboxes associated with these same fields are already in use in other forms, so I want to keep the values consistent.
yes - if you read the code you see it checks for True
 
Thanks for the suggestion. Even though your instructions are clear I think either I'm messing up somewhere or what you're suggesting isn't actually what I need. Your suggestion just changes the content of the textbox; which doesn't help me since it's not bound to the appropriate field. Plus, for some reason, I can't initially disable the textbox, so the conditional formatting of it doesn't work.

Rather than fiddle around with this, I'm just going to leave all of the checkboxes as they are and leave all of them enabled. Like I said, it's self explanatory what boxes should be left alone. Thanks anyway!
 
I don't think you have done this part of my instructions

3. in the textbox on click event put me.mychkbox=not me.mychkbox
Since I don't know the names of your chackboxes, I've used mychkbox - you need to change this to the name of your checkbox
 
No, I did include that step and I did change the name as appropriate. The only thing I didn't do was hide the checkbox because I wanted to see how things reacted with each other.

This is really just a cosmetic change and I have a lot more functional changes that need to be made for other parts of the database--I'm rolling out one section at a time. So I'm just going to focus on those and then once everything else is taken care of I might come back to this.
 

Users who are viewing this thread

Back
Top Bottom