View Full Version : Reference Option Button Label


batwings
02-08-2010, 07:46 PM
Hi there,

I need some help with referencing controls,

I have a Report with a textbox that I am using to show which Option has been selected from an Option Group on a form.

The only way I have been able to do what I need is using a hidden text box with the following code:
=Forms!MyForm!MyOptionGroup
And then with multiple IIf statements like below in a visible text box,
=IIf([Text29]=1,"Oranges",IIf([Text29]=2,"Apples",IIf([Text29]=3,"Pears",IIf([Text29]=4,"Lemons",IIf([Text29]=5,"Limes")))))

But there must be a more direct way?

=Forms!MyForm!MyOptionGroup!MyOptionButton!MyCapti on?

How do I reference each one of the 5 Captions or Names of my Option Button Labels in the Option Group?

Galaxiom
02-08-2010, 08:31 PM
I would use a combo set up to display the text but bound to the form's option group value. Its Row Source would be a table with the translation of the value to text. I would use the same table to populate the captions in the Option Group. This allows a user to change the text without having to change the form design.

Cover the combo drop down button using a box with a background the same colour as the form. Set the combo properties to Enabled = No and Locked = Yes.

batwings
02-08-2010, 08:44 PM
Galaxiom

I have already tried using a combo box on my form for the 5 options and then passed the Option Names to a text box on my report with the following:
=Forms!MyForm!MyCombo.Column(0)
And this works well.

I'm just rying to do the same but using an option group and 5 buttons instead of the combo box. If I use the following in a text box all I get is the numerical ID for the Option button selections ex.1,2,3,4,5.
=Forms!MyForm!MyOptionGroup

I'm trying to get the Option Group, Option Button, Label Captions

I'll probably just stick with the hidden text box on the Report feeding the multiple IIF statements in the visible Text box as mentioned in my initial post.

Galaxiom
02-08-2010, 08:56 PM
My suggestion was to use a combo on the Report to translate the option group value to text. This allows the displayed text to be set in a table rather than being fixed in the IIF statements.

batwings
02-08-2010, 10:20 PM
Galaxiom

Sorry I misunderstood you, many thanks I will give it a try

vbaInet
02-09-2010, 02:09 AM
By the way, I don't think the combo box's drop-down arrow gets displayed when running a report.

DCrake
02-09-2010, 02:42 AM
Have you considered using the Choose() function

Function GetChoice(Ind As Integer) As String
GetChoice = Choose(Ind, "Apples", "Pears", "Oranges","Bananas","Grapes")
End Function

In your query/form you would pass it the index value from your option group, say 1 to 5

Such As Me.TxtBox = GetChoice(Me.OptionGroup)

so whatever index value you pass to it is uses the corresponding value. So if you passed 3 to the GetChoice() function it would return Oranges.

David