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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

counting values in a form

Status
Not open for further replies.

chainedtodesk

Programmer
Feb 26, 2003
112
US
i have a screening tool (test) that uses several option groups (50) and each response is vauled 1-5. i need to be able to count the values of each question. show how many of the 50 were answered 1, how many were 2 etc. can this be done with form values? Thanks
 
I assume these are bound controls. Take a look at the "dcount". You can put this in an unbound control but you may have to refresh, recalc the control to ensure as you enter questions the control gets updated. Depending on where you want to use these values you may just want to make some queries to sum these values.
 
How are ya chainedtodesk . . .

[ol][li]Put 5 unbound textboxes in the header or footer of the form. Name the textboxes [blue]i1, i2, i3, i4, i5[/blue].[/li]
[li]In the [blue]Tag[/blue] property of each Option Group, enter a question mark [purple]?[/purple] (no quotations please).[/li]
[li]Add a [blue]Command Button[/blue] then copy/paste the following to the buttons [blue]On Click[/blue] event:
Code:
[blue]   Dim idx As Integer, ctl As Control
   
   Me!i1 = 0
   Me!i2 = 0
   Me!i3 = 0
   Me!i4 = 0
   Me!i5 = 0
   
   For Each ctl In Me.Controls
      If ctl.Tag = "?" Then
         idx = Nz(Me(ctl.Name), 0)
         
         If idx > 0 Then
            Me("i" & idx) = Me("i" & idx) + 1
         End If
      End If
   Next[/blue]
[/li][/ol]
[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
thanks for the input, yes the fields are unbound and thats why i couldnt get dcount to work. i had used it previously in another application but couldnt make it work here so that answers that issue. thanks again MajP.

i will try the other suggestion supplied by TheAceMan1 since these are unbound, thanks TheAceMan1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top