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!

Count the times text shows

Status
Not open for further replies.

ptrifile

Technical User
Aug 10, 2004
457
US
I have a form that has about 10 different combo boxes on it. There are 3 choices in each combobox (YES, NO, N/A). If i want a textbox on the form to show how many times "YES" was chosen on the form how could i accomplish this?

Thanks for any help!

Paul
 
dhookom . . .

[blue]Nicely Done![/blue] [thumbsup2]

See Ya . . .

Be sure to see FAQ219-2884 Worthy Reading! [thumbsup2]
Also FAQ181-2886 Worthy Reading! [thumbsup2]
 
Isn't the OP saying that each record had 10 different combo boxes, and he wants to know, on a given record, how many of those 10 fields has 'Yes' selected? As opposed to how many records on the form has 'Yes' chosen for a single, given field? OR am I reading this wrong?

The Missinglinq

Richmond, Virginia

The Devil's in the Details!
 
ptrifile . . .

[blue]missinglinq[/blue] has asked a good question. Either way here's a function to start off with. In form design view make sure you add a question mark [blue]?[/blue] (no quotations please) to the [blue]Tag[/blue] property of each combobox. Then copy/paste the function below to the forms code module.

Code:
[blue]Public Function YesCnt() As Long
   Dim ctl As Control, cnt As Long
   
   For Each ctl In Me.Controls
      If ctl.Tag = "?" And Nz(ctl, "") = "Yes" Then
         cnt = cnt + 1
      End If
   End If
   
   YesCnt = cnt

End Function[/blue]

Finally the [blue]control source[/blue] of the textbox becomes:

Code:
 = YesCnt()

[blue]Your Thoughts? . . .[/blue]

See Ya . . .

Be sure to see FAQ219-2884 Worthy Reading! [thumbsup2]
Also FAQ181-2886 Worthy Reading! [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top