Reference Option Button Label

batwings

Registered User.
Local time
Today, 20:08
Joined
Nov 4, 2007
Messages
40
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:
Code:
=Forms!MyForm!MyOptionGroup
And then with multiple IIf statements like below in a visible text box,
Code:
=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!MyCaption?

How do I reference each one of the 5 Captions or Names of my Option Button Labels in the Option Group?
 
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.
 
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:
Code:
=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.
Code:
=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.
 
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.
 
Galaxiom

Sorry I misunderstood you, many thanks I will give it a try
 
By the way, I don't think the combo box's drop-down arrow gets displayed when running a report.
 
Have you considered using the Choose() function

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

Users who are viewing this thread

Back
Top Bottom