Results 1 to 2 of 2

Thread: Option buttons

  1. #1
    Join Date
    Oct 2009
    Posts
    204

    Unanswered: Option buttons

    I'm having a problem coding a button that uses option buttons as criteria. The first option button is called ReportToggle, and the second is called GraphToggle. For some reason I can't pull up the value in ciode....This is what I have so far....

    Code:
    Private Sub Command145_Click()
    
    If Me.ReportToggle.Value = True Then
    GoTo IsReport
    Else
    GoTo IsGraph
    End If
    
    IsGraph:
    If Me.GraphToggle.Value = True Then
    GoTo RunGraph
    Else
    GoTo NoneSelected
    End If
    
    NoneSelected:
    MsgBox ("Please Select Report Type: Report or Graph!"), vbOKOnly, "Report Error"
    Exit Sub
    
    IsReport:
    MsgBox ("This is a report.")
    Exit Sub
    
    RunGraph:
    MsgBox ("This is a graph.")
    Exit Sub
    
    End Sub
    Does anyone know what I did wrong?

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    If the option buttons are included in an option group you cannot do that. In this case, every option button has a value (1,2,3, etc.) and you have to test the value of the option group itself to know which option button is "on". The value of the option group will change and take the value of the option button you click on.
    Have a nice day!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •