If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Toggle buttons

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-07-07, 14:17
ottomatic ottomatic is offline
Registered User
 
Join Date: Sep 2003
Posts: 228
Toggle buttons

I am having the darndest time setting up a pair of toggle buttons so only one can be true at a time. any help out there?
Reply With Quote
  #2 (permalink)  
Old 02-08-07, 03:31
MikeTheBike MikeTheBike is offline
Registered User
 
Join Date: Apr 2004
Location: Derbyshire, UK
Posts: 714
Hi

Suggestions for toggle button

Code:
Private Sub CommandButton1_Click()
    Const cCaption1 As String = "Do Action ONE"
    Const cCaption2 As String = "Do Action TWO"
    
    With CommandButton1
    
        If .Caption = cCaption1 Then
            MsgBox "Action ONE code here"
           .Caption = cCaption2
        Else
            MsgBox "Action TWO code here"
            .Caption = cCaption1
        End If
    
    End With
    
End Sub
Basic but it works.

This assumes that you want differand captions depending on the toggle state !
MTB
Reply With Quote
  #3 (permalink)  
Old 02-08-07, 12:50
shades shades is offline
Registered User
 
Join Date: Oct 2003
Posts: 1,091
Howdy. Are you using this in VBA or Excel?

If in VBA, then follow Mike's advice.

If in Excel are you using Forms toolbar or Control Toolbar? Simplest is to use the Option buttons on the Forms toolbar (and allows backward compatibility with XL97 and cross-compatibility with XL on the Mac).
__________________
old, slow, and confused
but at least I'm inconsistent!

Rich
(retired Excel 2003 user, 3/28/2008)

How to ask a question on forums
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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