Using option groups

M

Maury Markowitz

Here's my task:

Users want to select one of a number of possible options. when they
select one, it is written out as a text value to a table. These
options are subject to change at any time, the list will be changing
often.

I decided that the best UI for this task would be an option group -
yes, a pop-up would work, but would not be as easy to use - the user
needs to study the entire list to see which selection is appropriate.

So I made an OptionGroup, placed Option Buttons in them, and changed
the option button's associated labels to be the different selections.
This way I can easily modify the list simply by changing the caption
on the label, or alternately adding and removing buttons.

I'm stumped how to read the text in the label though. I found that if
you trap the AfterUpdate on the _group_ the control number is
returned, so I did this...

AttributionGroup.Controls(AttributionGroup.value)

which returns the right control number, for instance, "2". I can use
that handle to talk to the selected control, but what question do I
ask it? What is the path to the label associated with that option
button?

Maury
 
M

Maury Markowitz

Ok, now I'm more confused than ever...

I made a new form
I added an Option Group
I placed four option buttons in it
I changed the _option button name_ (NOT the label) to the text value I
want
I added a AfterUpdate handler...

Private Sub TestGroup_AfterUpdate()
MsgBox TestGroup.Controls(TestGroup.value).name
End Sub

So far so good...

Click on button one. MsgBox has the button's name it in. Nice! Click
on button two... get the _name of the label_. Click on button three,
name of button. Button four, name of label.

Does anyone have any idea what's going on here?

Maury
 
S

Stuart McCall

Maury Markowitz said:
Further info:

Using the debugger I found that that label appears to be part of the
option button's own controls collection, item 1. So I did this...

That statement is incorrect. The controls collection is zero-based, so what
you need is:

AttributionWhoGroup.Controls(AttributionWhoGroup.value).Controls(0).Caption

<snip>
 
M

Maury Markowitz

That statement is incorrect. The controls collection is zero-based, so what
you need is:

AttributionWhoGroup.Controls(AttributionWhoGroup.value).Controls(0).Caption

Doesn't work, unfortunately. It seems the labels are part of the
_group_ collection, not the button itself. Or something like that
anyway, the call fails for half of the controls, and not the other
half!

Maury
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top