How to test Option Group values with VBA

How do I use VBA to find the value of an option group?  Can you give me an example using two options.

schmir1Asked:
Who is Participating?
 
Jim Dettman (Microsoft MVP/ EE MVE)Connect With a Mentor President / OwnerCommented:

  and to be clear, you replace everything in the <> with the actual name of the control.  For example, if the control was named grpReportType, then you'd use:

  If Me.grpReportType = 3 then
    ' do this report
  ElseIf Me.grpReportType = 2 then
    ' do that report
  Else
     MsgBox "Invalid report type"
  End If

  An alternative to the above would be to use a Select CASE statement

  Select Case grpReportType

  Case 3
     ' do this report
  Case 2
     ' do that report
  Case Else
     MsgBox "Invalid report type"
  End Select

JimD.
 
0
 
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:

  Not sure I understand the question.  If you have an option group, you simply refer to the group control:

  Me.<name of my group control>

  To get it's value.

JimD.
0
 
schmir1Author Commented:
Thanks.  I had a mental block about the Frame being the Group.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.