how to use the option buttons in VBA

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ahmed222too
    New Member
    • Sep 2007
    • 47

    how to use the option buttons in VBA

    how to use the option buttons in VBA (how to call the value of the option buttons ) and is it must to gather the option buttons in one option group ?

    thanks
  • missinglinq
    Recognized Expert Specialist
    • Nov 2006
    • 3533

    #2
    You use an Option Group if you want to limit your user to one option out of a group of options! Only one option at a time can be selected from an option group. When you create an Option Group, the group is given a name such as Frame0 or Frame2. This is how you must refer to the group; when a value is chosen, such as the third button or option, that is the value of the Frame or Option Group. Each button, when clicked, assigns its value to the Frame or Option Group. The first button is assigned 1, the second button 2, and so forth. You cannot directly assign text values to an Option Group. Here's an example that pops up an message box telling you which button in an Option Group has been selected:
    Code:
    Private Sub YourFrameName_AfterUpdate()
      Select Case YourFrameName
    	Case 1
    	  MsgBox "First Button"
    	Case 2
    	  MsgBox "Second Button"
    	Case 3
    	  MsgBox "Third Button"
      End Select
    End Sub
    An individual button, one not in an Option Group, is referred to in this manner:
    Code:
    Private Sub OptionButton_AfterUpdate()
     If OptionButton = -1 Then
       MsgBox "Button is Checked!"
     Else
       MsgBox "Button is Not Checked!"
     End If
    End Sub
    Hope this helps!

    Linq ;0)>

    Comment

    Working...