Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Setting ToggleButton Value


Is there a way to set the value of a toggle button without triggering a
click event? I have a set of three buttons that I want to deselect the
other two options when any one is selected.

ie.
Private Sub ToggleButton1_Click()
ToggleButton1.Value = True
ToggleButton2.Value = False
ToggleButton3.Value = False
End Sub

When I set the value of the other two it seems to trigger a click event
on them as well.

I have tried the example of exclusive toggle buttons on ms site
(http://support.microsoft.com/?kbid=213714) but couldn't get it to
work. It seemed to save all the calls to the sub until I closed the
form.


--
fazstp
------------------------------------------------------------------------
fazstp's Profile: http://www.excelforum.com/member.php...o&userid=30574
View this thread: http://www.excelforum.com/showthread...hreadid=507025

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Setting ToggleButton Value

You can add a public variable, set it to something, check it and then have each
_click event check that variable:

Dim blkProc as boolean

Private Sub ToggleButton1_Click()
blkproc = true
ToggleButton2.Value = False
ToggleButton3.Value = False
blkproc = false
End Sub

Private Sub ToggleButton2_Click()
if blkproc = false then exit sub
'existing code here
End Sub

I'm not quite sure why you would be setting button1 to true in the
togglebutton1_click event, though.

fazstp wrote:

Is there a way to set the value of a toggle button without triggering a
click event? I have a set of three buttons that I want to deselect the
other two options when any one is selected.

ie.
Private Sub ToggleButton1_Click()
ToggleButton1.Value = True
ToggleButton2.Value = False
ToggleButton3.Value = False
End Sub

When I set the value of the other two it seems to trigger a click event
on them as well.

I have tried the example of exclusive toggle buttons on ms site
(http://support.microsoft.com/?kbid=213714) but couldn't get it to
work. It seemed to save all the calls to the sub until I closed the
form.

--
fazstp
------------------------------------------------------------------------
fazstp's Profile: http://www.excelforum.com/member.php...o&userid=30574
View this thread: http://www.excelforum.com/showthread...hreadid=507025


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Setting ToggleButton Value


Thanks for that. That did the trick. The reason for setting the state of
the clicked button to True is so that there is always at least one
button selected, otherwise clicking the already selected option leaves
all buttons deselected.


--
fazstp
------------------------------------------------------------------------
fazstp's Profile: http://www.excelforum.com/member.php...o&userid=30574
View this thread: http://www.excelforum.com/showthread...hreadid=507025

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Setting ToggleButton Value

Most people use optionbuttons for this effect. Users are used to that
paradigm.

--
Regards,
Tom Ogilvy


"fazstp" wrote in
message ...

Thanks for that. That did the trick. The reason for setting the state of
the clicked button to True is so that there is always at least one
button selected, otherwise clicking the already selected option leaves
all buttons deselected.


--
fazstp
------------------------------------------------------------------------
fazstp's Profile:

http://www.excelforum.com/member.php...o&userid=30574
View this thread: http://www.excelforum.com/showthread...hreadid=507025



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Setting ToggleButton Value


Can you have two groups of three optionbuttons on one form (ie.
selecting one of three options for two different variables)?


--
fazstp
------------------------------------------------------------------------
fazstp's Profile: http://www.excelforum.com/member.php...o&userid=30574
View this thread: http://www.excelforum.com/showthread...hreadid=507025



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Setting ToggleButton Value

Sure. One property of an ActiveX (control toolbox toolbar) optionbutton is
the groupname.

Pick any name and assign it to each of the first three (first group). Pick
any other name and assign it to each of the next three.

You can also put two frames on the Userform, then put 3 optionbuttons in
each.

--
Regards,
Tom Ogilvy



"fazstp" wrote in
message ...

Can you have two groups of three optionbuttons on one form (ie.
selecting one of three options for two different variables)?


--
fazstp
------------------------------------------------------------------------
fazstp's Profile:

http://www.excelforum.com/member.php...o&userid=30574
View this thread: http://www.excelforum.com/showthread...hreadid=507025



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ToggleButton to Unprotect/Protect all worksheets Kellascat Excel Discussion (Misc queries) 0 November 9th 09 07:30 PM
ActiveX ToggleButton Reset John Excel Discussion (Misc queries) 2 May 13th 09 11:27 PM
Help with togglebutton that displays jpg caj Excel Discussion (Misc queries) 2 March 7th 07 02:44 PM
need help with togglebutton Gary Keramidas[_2_] Excel Programming 7 July 9th 05 04:15 PM
2 macros in a Togglebutton? Jorge[_2_] Excel Programming 1 August 11th 03 01:57 AM


All times are GMT +1. The time now is 01:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"