Link to home
Start Free TrialLog in
Avatar of pdvsa
pdvsaFlag 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
Avatar of pdvsa
pdvsa
Flag of United States of America image

ASKER

I get an error when the form opens if I use that code.
Avatar of 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
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 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
Can you post a sample of your database in .mdb (Access 2003 ) format?   Just the relevant forms, etc would be fine.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 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.
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,
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.