number of options for groupOption

A

Allen Browne

It is possible to determine how many option buttons are in an option group
by examining its Controls collection.

Loop like this:
For Each ctl In Me.[MyOptionGroup].Controls
Examine the ControlType of each, and count how many are acOptionGroup.

It is not really practical to add more option buttons to the group at
runtime.
 
G

Guest

This is not my question.
To count the number of acOptionGroup or another control I know, one example
is following your suggestion

What I need is to count the options in each acOptionGroup.
For example I have a form with 4 acOptionGroup, and I have 2 acOptionGroup
with 2 options and another 2 with 5 options.

I don't know if is possible. I looked to properties for acOptionGroup and I
didn't see the number of options.
--
Jose


Allen Browne said:
It is possible to determine how many option buttons are in an option group
by examining its Controls collection.

Loop like this:
For Each ctl In Me.[MyOptionGroup].Controls
Examine the ControlType of each, and count how many are acOptionGroup.

It is not really practical to add more option buttons to the group at
runtime.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

JCP said:
Is it possibel for each groupOption to know how many options it has?
Thanks
jcp
 
A

Allen Browne

Function HowManyOptionButtons(grp As OptionGroup) As Integer
Dim ctl As Control
Dim i As Integer
For Each ctl In grp.Controls
If ctl.ControlType = acOptionButton Then
i = i + 1
End If
Next
HowManyOptionButtons = i
End Function

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

JCP said:
This is not my question.
To count the number of acOptionGroup or another control I know, one
example
is following your suggestion

What I need is to count the options in each acOptionGroup.
For example I have a form with 4 acOptionGroup, and I have 2 acOptionGroup
with 2 options and another 2 with 5 options.

I don't know if is possible. I looked to properties for acOptionGroup and
I
didn't see the number of options.
--
Jose


Allen Browne said:
It is possible to determine how many option buttons are in an option
group
by examining its Controls collection.

Loop like this:
For Each ctl In Me.[MyOptionGroup].Controls
Examine the ControlType of each, and count how many are acOptionGroup.

It is not really practical to add more option buttons to the group at
runtime.

JCP said:
Is it possibel for each groupOption to know how many options it has?
Thanks
jcp
 
G

Guest

Hi Allen,
I tested and it works well
Thanks a lot
Regards
jcp
--
Jose


Allen Browne said:
Function HowManyOptionButtons(grp As OptionGroup) As Integer
Dim ctl As Control
Dim i As Integer
For Each ctl In grp.Controls
If ctl.ControlType = acOptionButton Then
i = i + 1
End If
Next
HowManyOptionButtons = i
End Function

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

JCP said:
This is not my question.
To count the number of acOptionGroup or another control I know, one
example
is following your suggestion

What I need is to count the options in each acOptionGroup.
For example I have a form with 4 acOptionGroup, and I have 2 acOptionGroup
with 2 options and another 2 with 5 options.

I don't know if is possible. I looked to properties for acOptionGroup and
I
didn't see the number of options.
--
Jose


Allen Browne said:
It is possible to determine how many option buttons are in an option
group
by examining its Controls collection.

Loop like this:
For Each ctl In Me.[MyOptionGroup].Controls
Examine the ControlType of each, and count how many are acOptionGroup.

It is not really practical to add more option buttons to the group at
runtime.

Is it possibel for each groupOption to know how many options it has?
Thanks
jcp
 

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