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.

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
     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

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.

schmir1Author Commented:
Thanks.  I had a mental block about the Frame being the Group.
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.