Toggle button color changes

  • Thread starter Thread starter Tim
  • Start date Start date
Tim said:
How do change the color of a toggle button (background or text) when
it's down or up?


Depends on whether the toggle button is an separate control
or if it's in a option group frame.

By itself:

Private Sub Toggle1_Click()
If Toggle1 = True Then
Toggle1.ForeColor = vbGreen
Else
Toggle1.ForeColor = vbRed
End If
End Sub

In a frame:

Private Sub Frame2_AfterUpdate()
Dim ctl As Control
For Each ctl In Frame2.Controls
If ctl.ControlType = acToggleButton Then
If ctl.OptionValue = Frame2 Then
ctl.ForeColor = vbGreen
Else
ctl.ForeColor = vbRed
End If
End If
Next ctl
End Sub

Note that you can not change the background color of a
button, so ForeColor is your only choice.
 
Back
Top