Avatar of pdvsa
pdvsa
Flag for United States of America asked on

Option Box - change color if Yes option selected

Experts,

I have an option box on the form.
Yes = -1  No = 0

I want to somehow highlight the label "Yes" or color the Yes option button if Yes is selected.  I am trying to make it easier to see if the Yes button is selected.

I thought I could do something like the below but I dont think this is the correct approach.  

let me know...thanks


Private Sub Form_Current()

If Me.Option211 = -1 Then
        Me.Option211.BorderColor = vbRed
    Else
        Me.Option211.BorderColor = vbBlack
    End If
Microsoft Access

Avatar of undefined
Last Comment
mbizup

8/22/2022 - Mon
pdvsa

ASKER
I get an error when the form opens if I use that code.
mbizup

Your options (the radio buttons) have associated VALUEs under the data tab on the property shgeet of each option.

Those values are probably 1 and 2 -- but you need to double check this:


If Me.Option211 = 1 Then
        Me.Label1Name.BorderColor = vbRed   '<--- Highlight the LABELS next to each option (I dont think you can change the color of a radiobutton)
    Else
        Me.Label1Name.BorderColor = vbBlack
    End If 

Open in new window

ASKER CERTIFIED SOLUTION
mbizup

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
pdvsa

ASKER
Mbizup...thanks....
<Those values are probably 1 and 2 -- but you need to double check this:
==>I do actually have a value of -1.  I converted from a YesNo field to option box or something like that.  Cant remember.  

The Frame doesnt have a value as far as I can see. Value is Null.  
I do not have an error when using the frame code you provided but ti doesnt change any colors.  

this is what I am using:  
Private Sub Form_Current()

If Me.Frame208 = -1 Then
        Me.Label212.BorderColor = vbRed   '<--- Highlight the LABELS next to each option (I dont think you can change the color of a radiobutton)
    Else
        Me.Label212.BorderColor = vbBlack
    End If


I get an error of "You entered an expression that has no value":

Private Sub Form_Current()
    If Me.Option211 = -1 Then
        Me.Label212.BorderColor = vbRed   '<--- Highlight the LABELS next to each option (I dont think you can change the color of a radiobutton)
    Else
        Me.Label212.BorderColor = vbBlack
    End If
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
mbizup

Can you post a sample of your database in .mdb (Access 2003 ) format?   Just the relevant forms, etc would be fine.
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
pdvsa

ASKER
Jeff:  that was nice bit of code.  I applied it to my side and I have it working now.  thanks for the help.  

Not sure how to score.
Jeffrey Coachman

Split the points to keep it simple.

mbizups code should work as well, so please work with her to verify, as she posted her solution before I posted mine.

There is nothing I did in my sample that mbizup could not have done...

Neither of us are in any rush to get any points, so don't feel pressured...

The main thing is that you get a solution (or two) for your issue.
;-)

Jeff

Besides,
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
mbizup

Sounds fair to me.  I am 110% certain we could get that code working in your environment  and explained in  short order with the right control names and properties -- which is why my last comment was asking for a sample of your database :-)


Happy to work with it if you are interested.