Depending on what you need in your application you can have the click of button set it's caption so it becomes the word Clicked or you could disable the button so it would become grayed out.
The second option would mean there would need to be something set up so if you needed it the button could be enabled and clicked once again.
Basically, your code would look something like this for the On Click :
Private Sub Toggle7_Click()
If Toggle7.Caption = "Not Clicked" Then
Toggle7.Caption = "clicked"
Toggle7.ForeColor = vbRed
ElseIf Toggle7.Caption = "Clicked" Then
Toggle7.Caption = "Not clicked"
Toggle7.ForeColor = vbBlack
End If
How would you have the toggle Switch change the BackColor when depressed.
I tried removing ForeColor from the code below and adding BackColor but nothing happened.
Private Sub Toggle7_Click()
If Toggle7.Caption = "Not Clicked" Then
Toggle7.Caption = "clicked"
Toggle7.BackColor = vbRed
ElseIf Toggle7.Caption = "Clicked" Then
Toggle7.Caption = "Not clicked"
Toggle7.BackColor = vbBlack
End If
End Sub
In the case of the Access command buttons the background color property is not exposed. I know in VB there is a graphics mode for the buttons that will allow you to change the back ground color.
The only work around that I know of is to set a rectangle with the color and raised style the overlay it with a transparent button so the on click event can be used.
Have you tried using a label? With a label you can set the specialeffect sunken/raised and backcolor programmaticaly, and it does also have a on click event. Something like this might be used:
[tt]If Me!lblTst.SpecialEffect=1 Then
Me!lblTst.SpecialEffect=2
Me!lblTst.BackColor = 15263976
Else
Me!lblTst.SpecialEffect=1
Me!lblTst.BackColor = -2147483633
End If[/tt]
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.