Toggle Button

  • Thread starter blackbox via OfficeKB.com
  • Start date
B

blackbox via OfficeKB.com

How can I make the caption of the toggle button to change based on wether it
is on or off.

On/Off Yes/No

just something simple like that.
 
N

NickHK

Whilst I would maybe question the logic of doing this because:
- The idea of the control is that its state is visible from its appearance
- Will the user be confused if they should click it to make if Off, or it
currently is Off. I prefer the CheckBox for clarity.

Ignores the Null state, which you can add if desired.

Private Sub ToggleButton1_Click()

With ToggleButton1
If .Value = True Then
.Caption = "On"
Else
.Caption = "Off"
End If
End With

End Sub

NickHK
 
I

Incidental

Hi there

you could use something like this

Private Sub ToggleButton1_Click()

If ToggleButton1.Value = True Then
ToggleButton1.Caption = "On"
Else
ToggleButton1.Caption = "Off"
End If

End Sub

Hope this helps
 
B

blackbox via OfficeKB.com

Perfect

Thanks!
Hi there

you could use something like this

Private Sub ToggleButton1_Click()

If ToggleButton1.Value = True Then
ToggleButton1.Caption = "On"
Else
ToggleButton1.Caption = "Off"
End If

End Sub

Hope this helps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top