Change back color or border color based on yes/no check box (1 Viewer)

hubbz821

New member
Local time
Today, 01:58
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
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 22:58
Joined
Aug 30, 2003
Messages
36,115
If it's a checkbox, the value isn't text. Try

If FollowUp1 = yes then
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 22:58
Joined
Aug 30, 2003
Messages
36,115
By the way, you might want an Else clause to handle the user unchecking the box. This may be helpful:

 

CJ_London

Super Moderator
Staff member
Local time
Today, 05:58
Joined
Feb 19, 2013
Messages
16,521
also there are vba names for standard colours

vbRed
vbGreen
vbBlack
etc

so you don't need your RED variable
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 00:58
Joined
Feb 28, 2001
Messages
26,946
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.
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 22:58
Joined
Aug 30, 2003
Messages
36,115
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.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 05:58
Joined
Jul 9, 2003
Messages
16,224
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:

Gigitty

Member
Local time
Yesterday, 22:58
Joined
Mar 29, 2007
Messages
52
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.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 05:58
Joined
Jul 9, 2003
Messages
16,224
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

Top Bottom