Toggle Button

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
 
B

Bob Phillips

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)
 
T

Tom Ogilvy

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
 
Top