Create a Form to Return the Value Selected by a user from an Option Group
Posted on 2004-11-18
I have a form created in Access that has an Option Group with 12 options. I want the captions of these options and number of options displayed to be dynamic. I have been able to create and call a function on a form to dynamically hide and show the appropriate options as shown below.
Public Function ShowOptions(strOptnList() As String)
Dim intx As Integer
Dim strOptnLbl As String
Dim frm As Form_frm_OptionList
For intx = 1 To UBound(strOptnList)
strOptnLbl = "lblOptn" & intx
Me(strOptnLbl).Visible = True
Me(strOptnLbl).Caption = strOptnList(intx)
Me("Optn" & intx).Visible = True
What I would really like to do, however, is to call this form from anywhere within my program and have it return the selected option to the calling function. I know this can be accomplished by creating a global variable to store the option value in, but I was hoping there was some way of making this form(function) more portable to prevent the need of always declaring a global variable in any application I use such a form in.
Is there a way to call this form and have it return back the user's selection without declaring a global variable.
I found code to accomplish a similar thing in VB, but have not been able to do in Access.