Hiding checkboxes depending on the value of another field. (1 Viewer)

Lkwdmntr

Registered User.
Local time
Today, 01:31
Joined
Jul 10, 2019
Messages
277
Hi Guys,

I just wanted to put this one out there again. I have daily forms for the week and they have actions that need to be marked off with checkboxes. Depending on the value of one of my other fields, I want to hide or lock a couple of checkboxes.

If I could even gray them out or anything to sway users from entering a check when they shouldn't.

The appearance on the form is like this

Field1[Action] - Feild2[Tab1] - Chkbox1Yes - Chkbox2No Field3[Tab2]-Chkbox3Yes - Chkbox4No

If there is a value in both Tab1 and Tab2 then I don't need to lock anything.

It's when there is no value in Tab1 that I need to lock Chkbox1 and Chkbox2.

Also, if there is no value in Tab2 then I need to lock Chkbox3 and Chkbox4.

I know conditional formatting doesn't like checkboxes. I am hoping there is a solution. When I tried to lock the boxes with VBA, it locked them for all the records.

Any help would be greatly apreciated.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 01:31
Joined
Oct 29, 2018
Messages
21,357
Hi. There was a discussion on this same topic recently. Check out the similar threads links below. Otherwise, I'll see if I can find a link for you.


Edit: This is the one I was thinking about. Hope it helps...
 

isladogs

MVP / VIP
Local time
Today, 08:31
Joined
Jan 14, 2017
Messages
18,186
Thanks DBG. This time you beat me to it. Remarkably similar threads!
I notice the OP at the other thread went AWOL.
 

Micron

AWF VIP
Local time
Today, 04:31
Joined
Oct 20, 2018
Messages
3,476
When I tried to lock the boxes with VBA, it locked them for all the records.
That sounds like the checkboxes are not bound.
 

Lkwdmntr

Registered User.
Local time
Today, 01:31
Joined
Jul 10, 2019
Messages
277
So if I used conditional formatting on the Tab1 field. It would look something like this. Please make any corrections needed for this statement.

=IIf([Tab1] Is Not Null, "STCYes.disabled"and STCNo.disabled", "STCYes.enabled"and STCNo.enabled" )​

Just guessing here.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 01:31
Joined
Oct 29, 2018
Messages
21,357
So if I used conditional formatting on the Tab1 field. It would look something like this. Please make any corrections needed for this statement.
=IIf([Tab1] Is Not Null, "STCYes.disabled"and STCNo.disabled", "STCYes.enabled"and STCNo.enabled" )​
Just guessing here.
Hi. Is that from trying out Colin's demo in the other thread?
 

isladogs

MVP / VIP
Local time
Today, 08:31
Joined
Jan 14, 2017
Messages
18,186
Did you look at the link in post #2?

EDIT Looks like DBG got there first again....

I can't make any sense of that IIf statement but its definitely incorrect.
For info, my example in the link isn't using CF
 
Last edited:

Lkwdmntr

Registered User.
Local time
Today, 01:31
Joined
Jul 10, 2019
Messages
277
If I use VBA, whatever I program happens to all the checkboxes in the subform.

The IIf statement was in one of the examples
IIf([Field1]=[Field2],"R","") - was the example.

I think conditional formatting is the way to go, just need a little help with the statement.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 01:31
Joined
Oct 29, 2018
Messages
21,357
If I use VBA, whatever I program happens to all the checkboxes in the subform.

The IIf statement was in one of the examples
IIf([Field1]=[Field2],"R","") - was the example.

I think conditional formatting is the way to go, just need a little help with the statement.
Hi. I'll let Colin explain his demo to avoid further confusion here. Good luck!
 

isladogs

MVP / VIP
Local time
Today, 08:31
Joined
Jan 14, 2017
Messages
18,186
If I use VBA, whatever I program happens to all the checkboxes in the subform.

The IIf statement was in one of the examples
IIf([Field1]=[Field2],"R","") - was the example.the desired behaviour.

I think conditional formatting is the way to go, just need a little help with the statement.

As the other thread makes clear you cannot
a) use conditional formatting on checkboxes.
b) selectively enable/disable or show/hide controls on continuous forms. Its all or nothing as you are displaying multiple instances of the same control

What you can do is use an unbound control with an iif expression to mimic the desired behaviour.
In my example a label caption is used so it mimics a checkbox when the condition is true or is blank when its false. Perhaps you can adapt that for your own purposes ...but remember that you can't use CF on a label either.
Good luck.
 

Users who are viewing this thread

Top Bottom