Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: Counting number of selected Radio/Option Buttons


Message #1 by "Tim Maher" <tim.maher@s...> on Tue, 25 Mar 2003 11:46:42 +0000
Hi,

I have a form with 10 Option Buttons (opt_1, opt_2,......,opt_10) what
I need to to is on a cmd_click check if any buttons are selected and
then run a loop relating to how many buttons have neem selected.  For
example, if 5 of the 10 have been checked I need to run the main loop 5
times.  Also, each option button has a unique value associated with it,
is there anyway that on each pass of the loop I can get a value from
each option button.

Many thanks

Tim
This e-mail transmission is strictly confidential and intended solely 
for the person or organisation to who it is addressed.  It may contain 
privileged and confidential information and if you are not the 
intended recipient, you must not copy, distribute or take any action 
in reliance on it.  
If you have received this email in error, please notify us as soon as 
possible and delete it.
This e-mail has been scanned using Anti-Virus software, however, 
Swansea NHS Trust accept no responsibility for infection caused by 
any virus received on the recipients system.



Message #2 by Claudio de Biasio <cdebiasio@t...> on Tue, 25 Mar 2003 12:53:33 +0100 (CET)
Hi Tim!

Your email is a little bit confusing... but I think we can go throught that 
without problems! :-)

First of all, you have Check Boxes, not Option Buttons, or you could NOT select 
more than one of them... right? If this is not your case, just let me know what 
you are trying to communicate the user (what is your form showing).

Second, you will probably be running a loop just once, doing something each 
time your code comes across a checked item... or, am I wrong? Even here, let me 
know if I missed something.

Finally, for sure you can have the value of the check box, and you know that 
because you are DEALING with that in THAT specific pass of the loop! Unless you 
are referring to something else, as (e.g.) having the need to store a certain 
value somewhere else (usually, in group boxes the group box itself is the 
holder of the selected option value).

HTH, let me know what I didn't understand!

   Claudio de Biasio
     Team 97 S.r.l.


Quoting Tim Maher <tim.maher@s...>:

> Hi,
> 
> I have a form with 10 Option Buttons (opt_1, opt_2,......,opt_10) what
> I need to to is on a cmd_click check if any buttons are selected and
> then run a loop relating to how many buttons have neem selected.  For
> example, if 5 of the 10 have been checked I need to run the main loop 5
> times.  Also, each option button has a unique value associated with it,
> is there anyway that on each pass of the loop I can get a value from
> each option button.
> 
> Many thanks
> 
> Tim
> This e-mail transmission is strictly confidential and intended solely 
> for the person or organisation to who it is addressed.  It may contain 
> privileged and confidential information and if you are not the 
> intended recipient, you must not copy, distribute or take any action 
> in reliance on it.  
> If you have received this email in error, please notify us as soon as 
> possible and delete it.
> This e-mail has been scanned using Anti-Virus software, however, 
> Swansea NHS Trust accept no responsibility for infection caused by 
> any virus received on the recipients system.
> 
> 
> 
> 
> 
Message #3 by "Derrick Flores" <derrickflores@s...> on Tue, 25 Mar 2003 21:27:27 -0600
Tim,
You can use an array to determine how many time to loop and which unique
values to use.

Dim i As Integer
Dim varData(9) As String
If Me.opt1.Value = True Then
    varData(i) = "a"
    i = i + 1
End If
If Me.opt2.Value = True Then
    varData(i) = "b"
    i = i + 1
End If
If Me.opt3.Value = True Then
    varData(i) = "c"
    i = i + 1
End If
If Me.opt4.Value = True Then
    varData(i) = "d"
    i = i + 1
End If
If Me.opt5.Value = True Then
    varData(i) = "e"
    i = i + 1
End If
If Me.opt6.Value = True Then
    varData(i) = "f"
    i = i + 1
End If
If Me.opt7.Value = True Then
    varData(i) = "g"
    i = i + 1
End If
If Me.opt8.Value = True Then
    varData(i) = "h"
    i = i + 1
End If
If Me.opt9.Value = True Then
    varData(i) = "i"
    i = i + 1
End If
If Me.opt10.Value = True Then
    varData(i) = "j"
    i = i + 1
End If

Dim intI As Integer
For intI = 0 To i - 1
    If IsArray(varData) = True Then
        'Add you process there
        MsgBox varData(intI)
        
    End If
Next

Good Luck,
Derrick Flores
San Antonio, Texas


-----Original Message-----
From: Tim Maher [mailto:tim.maher@s...] 
Sent: Tuesday, March 25, 2003 5:47 AM
To: Access
Subject: [access] Counting number of selected Radio/Option Buttons

Hi,

I have a form with 10 Option Buttons (opt_1, opt_2,......,opt_10) what
I need to to is on a cmd_click check if any buttons are selected and
then run a loop relating to how many buttons have neem selected.  For
example, if 5 of the 10 have been checked I need to run the main loop 5
times.  Also, each option button has a unique value associated with it,
is there anyway that on each pass of the loop I can get a value from
each option button.

Many thanks

Tim
This e-mail transmission is strictly confidential and intended solely 
for the person or organisation to who it is addressed.  It may contain 
privileged and confidential information and if you are not the 
intended recipient, you must not copy, distribute or take any action 
in reliance on it.  
If you have received this email in error, please notify us as soon as 
possible and delete it.
This e-mail has been scanned using Anti-Virus software, however, 
Swansea NHS Trust accept no responsibility for infection caused by 
any virus received on the recipients system.






  Return to Index