How to test Option Group values with VBA

Posted on 2008-11-14
Last Modified: 2012-08-13
How do I use VBA to find the value of an option group?  Can you give me an example using two options.

Question by:schmir1
    LVL 56

    Expert Comment

    by:Jim Dettman (Microsoft MVP/ EE MVE)

      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.

    LVL 56

    Accepted Solution


      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


    Author Comment

    Thanks.  I had a mental block about the Frame being the Group.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    This isn't a frequent question on EE. I must have seen it three or four times (among several thousand questions). However, I use this trick quite often, most frequently as a delayed Current event. A form does not expose it's calculation dependenc…
    Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
    Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
    In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now