Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Toggle button color

Status
Not open for further replies.

Reils99

Programmer
Aug 3, 2010
3
US
I have an option group which uses toggle buttons. Upon key press the color is very similar to the unselected buttons. How can I assign a button color i.e. yellow based upon "key press".

This would help my users....

Thank you
 
The toggle button backgrounds will use the windows default colors scheme. You can use some code to set the caption color and font bold like:
Code:
Private Sub grpToggleColors_AfterUpdate()
    Dim itm
    On Error Resume Next
    For Each itm In Me.grpToggleColors.Controls
        itm.ForeColor = IIf(Me.grpToggleColors = itm.OptionValue, vbRed, vbBlack)
        itm.FontBold = IIf(Me.grpToggleColors = itm.OptionValue, True, False)
    Next
End Sub

Duane
Hook'D on Access
MS Access MVP
 

Thank you so much...after I inserted the VB it worked perfectly! One last question...I need to reset the button upon a new record. I imagine the code is simple...but for me impossible. Any idea how I can reset the colors to their defaults after the record is updated.

Thank you
 
It seems you want to run the same code in the On Current event of the form. You might be able to use this code in the On Current event:
Code:
   grpToggleColors_AfterUpdate

Duane
Hook'D on Access
MS Access MVP
 
I'm sorry but I'm confused.
Instead of placing the code for each "frame" as I did below...
Private Sub Frame239_AfterUpdate()
Dim itm
On Error Resume Next
For Each itm In Me.Frame239.Controls
itm.ForeColor = IIf(Me.Frame239 = itm.OptionValue, vbRed, vbBlack)
itm.FontBold = IIf(Me.Frame239 = itm.OptionValue, True, False)
Next
End Sub

You think I should place the code in OnCurrent? When I tried it I can't get the text to change colors.
I have 13 frame/option groups that I'm tgrying to get to reset to the default colors upon saving a record.
I appreciate your time...Thank you
 
I believe Duane was suggesting you call the AfterUpdate function from the OnCurrent event handler.

Code:
Private Sub Frame239_AfterUpdate()
....
End Sub

Private Sub Frame239_OnCurrent()
    Frame239_AfterUpdate
End Sub

Jeff
[small][purple]It's never too early to begin preparing for [/purple]International Talk Like a Pirate Day
"The software I buy sucks, The software I write sucks. It's time to give up and have a beer..." - Me[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top