Change back color or border color based on yes/no check box

hubbz821

New member
Local time
Today, 15:25
Joined
Jan 29, 2020
Messages
1
Hi,

I am trying to change the color of a label based on the whether a box is checked or not. Below is what I have but it does not do anything. I have tried it on form load, after update of check box and on current. Any help is appreciated. Thank you!

Private Sub Followup1_afterUpdate()
Dim RED

RED = RGB(255, 0, 0)

If FollowUp1 = "yes" then

Me.followup1.bordercolor = RED
Me.followup1.borderwidth = 6

end if
end sub
 
If it's a checkbox, the value isn't text. Try

If FollowUp1 = yes then
 
By the way, you might want an Else clause to handle the user unchecking the box. This may be helpful:

 
also there are vba names for standard colours

vbRed
vbGreen
vbBlack
etc

so you don't need your RED variable
 
Since changing a check-box is always counted as a change and usually counted as a click, you might consider "OnChange" and "OnClick." If all else fails, remember that a change of a checkbox can only occur if the checkbox is (at least momentarily) in focus. So consider the "LostFocus" event.
 
I think I've always used the after update event to handle changes to a check box's value. Be it via click, hitting enter, whatever, the value is changing thus the after update event fires. At least that's my experience.
 
Have a look at the labels property sheet.. You might see that the background colour of the label is set to transparent. If it is, you won't see the colour even though you've changed it.

More info and a video explanation on my website here:-


See video at time index 2min
 
Last edited:
Have a look at the labels property sheet.. You might see that the background colour of the label is set to transparent. If it is, you won't see the colour even though you've changed it.

More info and a video explanation on my website here:-


See video at time index 2min
Thankyou for this post Uncle Gizmo. Couldn't figure out why I was having the same issue.
 
Thank you for your feedback @Gigitty, it is appreciated.

I have a product I thought might be of interest, but when I looked at my website I was surprised to find that the YouTube video is marked private in YouTube, but is visible on the website!


Somehow I've got that webpage in a right mess! Also, the correct download is missing and there are other issues with the website.

If you can view the "Nifty Option Group" Video (based on images) and you would like to test the product, let me know and I will send you a free copy.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom