Full Version: Option Group Button Colors
UtterAccess Forums > Microsoft® Access > Access Forms
Jboyle
Is there a way to vary an option group selected button text color or background color?
Thanks for the help - John
quest4
John, I don't know about background color, but text color is ForeColor. In the OnClick event you can probably put something like this:
If Me!cmdButton = True Then
Me!cmdButton.ForeColor = vbGreen
Else
Me!cmdButton.ForeColor = vbBlack'
End If
I have not worked very much with option group buttons, so I am assuming that they work like chkboxes, so I maybe work in that assumption, but the idea will work with a few changes. hth.
Jack Cowley
Code similar to this in the On Click event of the Option Group will change the background colors of the labels for the radio buttons or checkboxes...
Select Case OptionGroupName
Case 1
Me.Label6.BackStyle = 1
Me.Label6.BackColor = vbRed
Me.Label8.BackStyle = 0
Case 2
Me.Label8.BackStyle = 1
Me.Label8.BackColor = vbRed
Me.Label6.BackStyle = 0
End Select
Change option group and label names as appropriate...
hth,
Jack
Jboyle
Thanks a bunch....... Just looking at your code, I'm quite sure it will work just fine
gain, Thanks - John
quest4
Jack's code always work great.
Good suggestion, Jack.
Jboyle
I will add you and Jack to my list of one's to follow notworthy.gif
Jack Cowley
quest4 -
You were closer than I was to the correct code. I assumed radio buttons or check boxes and not command butttons, which is what he said in his post! You are correct in that you cannot change the color of the command button, just the forecolor. Code like this should work:
Select Case Frame12
Case 1
Me.Toggle15.ForeColor = vbRed
Me.Toggle16.ForeColor = vbBlack
Case 2
Me.Toggle16.ForeColor = vbRed
Me.Toggle15.ForeColor = vbBlack
End Select
Thanks for settiing me straigh!
Jack
Jack Cowley
I made an error in giving you code to change label background colors but your post said command buttons. quest4 was much closer than I in giving you the right code. Try something like this in the On Click event of the Option Group...

Select Case OptionGroupName
Case 1
Me.Toggle15.ForeColor = vbRed
Me.Toggle16.ForeColor = vbBlack
Case 2
Me.Toggle16.ForeColor = vbRed
Me.Toggle15.ForeColor = vbBlack
End Select

Change the names of the toggle buttons as necessary and sorry for the wrong code first time round...

Jack
quest4
Jack a thought here, I thought I saw something on Canace Tripp's website about changing color on cmdButtons. If you are interested click this link:
http://www.candace-tripp.com/_pages/access_downloads.asp
She has a lot of nice stuff there. Nice see you again Jack, good solution. Have a great day.
Jack Cowley
quest4 -
I am familiar with Candace Tripp's color command buttons, but I did not want to introduce another factor to the equation. I guess I am a step by step kinda guy... How about you post the web site to jboyle as you thought of it and then he can go that route if he likes. I think you should take the credit as you thought of it! Besides, you are doing a great job here and deserve some kudos!
Jack
JVanKirk
Just my two cents here, I stopped using command buttons almost entirely. I hate not being able to make the colors I want. I use labels now for everything. It takes a few extra steps to get the button feel but is well worth it. Check out the little demo I attached, it should give you some idea of how to accomplish a custom button using labels.
quest4
I agree, I to am a step by step guy also. Slow and steady wins the race, or so they say. I already left the link, that way he can decide for himself, as far as credit goes I have been one of those guys who likes to be in the shadows and help out when ever he can. Nice talking to you again Jack, and the dbase you helped out with is now in testing, it looks pretty good now. So thank you for all of that help you gave me, I learned alot from you. notworthy.gif
Jack Cowley
Thank you for your kind words. I'm glad to hear that your db is in testing and I hope it continues to do all that you want it to do...
I was thinking, rather briefly, about the toggle buttons in an Option Group and I am not sure that you can replace them using the methods spelled out by Candace Tripp. I have not tried it, but I think that you are probably stuck with the toggle buttons in an Option Group, but I could be wrong...
Jack
quest4
I have not yet work very much with Option Groups, so I was just making a few suggestions that work in other places. What he can do is make a copy of the dbase and play with the copy, and then so what if he crashes it. Sometimes that is the best way to learn, I have lost a couple that way myself.
Jack Cowley
LOL! Yep, we do lose them every now and again...unfortunately!
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.