Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

COUNT CHECKBOXES 1

Status
Not open for further replies.

mrwendell

Programmer
Aug 22, 2003
43
US
oh i am really feeling like an idiot...i have a access2000 form that contains checkboxes (10) per category (4). checkboxes were named check1to10 in the first category, check11 to 20 and so on... i want to count just the "yes" boxes for each category. because each category needs to be scored separately. i tried to put the following code on a command button...also on afterupdate...nothing! is there anyone who can help me get my dignity back!

Dim counta As Integer
For i = 1 to (10)
If Me("check" & i) = true Then counta = counta + 1
Next i
Me![subcomp1] = counta
 
Rename your checkboxes as Check1(0) to Check1(9), Check2(0) to Check2(9) etc. This makes a control array.

You can then loop through as you wanted to:
Dim counta As Integer
For i = 0 to 9
If Me.Check1(i) = true Then counta = counta + 1
Next i

Note that you're in the VB5/6 forum, and this looks like an Access VBA question.

If you are actually using this in VB5/6 then Checkboxes take one of three values:
CheckBox control — 0 is Unchecked (default), 1 is Checked, and 2 is Grayed (dimmed).

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
thanks johnwm...youre right wrong forum...i am still stuck on where to run the code...so i reposted in the vba forum.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top