Toggle Button

  • Thread starter Thread starter Keri
  • Start date Start date
K

Keri

I have a toggle button that when clicked ON I want to run
one code and when clicked OFF I want to run a different
code. Is this possible?? Please help me out.

--Keri
 
If it is a toolbar button, you can set and check its State property.

If it is a commandbutton, then you could use a global variable and set
/unset that,

Dim fStatus As Boolean

Private Sub CommandButton1_Click()

If fStatus Then
'do one thing
Else
'do an other
End If

fStatus = Not fStatus

End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Bob told you how to do it with a commandbutton and a forms button.

If it is a toggle button as you imply

Private Sub ToggleButton1_Click()
if ToggleButton1.Value = True then ' depressed
macro1
else
macro2
End if
End Sub
 

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

Back
Top