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

Calculation in report

Status
Not open for further replies.

bigdrewecu

Programmer
Apr 20, 2004
14
US
Ok i have 6 columns to where people can enter data for judges ie judge1 is jane doe judge2 is jim doe judge 3 is drew smith etc etc. I need a way to count the number of people in the record. I figured what i could do is do a loop and counter for the report open event but no such luck. Anyone have any suggestions? heres what i have...

Dim intcount As Integer
txtJudges.SetFocus
If Trim(txtJudges.Text) <> 0 Then
intcount = intcount + 1
End If
txtJudges2.SetFocus
If Trim([txtJudges2.Text]) <> 0 Then
intcount = intcount + 1
End If
txtJudges2.SetFocus
If Trim([txtJudges3.Text]) <> 0 Then
intcount = intcount + 1
End If
txtJudges2.SetFocus
If Trim([txtJudges4.Text]) <> 0 Then
intcount = intcount + 1
End If
txtJudges2.SetFocus
If Trim([txtJudges5.Text]) <> 0 Then
intcount = intcount + 1
End If
txtJudges2.SetFocus
If Trim([txtJudges6.Text]) <> 0 Then
intcount = intcount + 1
End If
 
I don't think you need to set the focus each time, and also, you checking in the string in the control is <> 0. I would think you either check that the LEN(string) <> 0 or string <> ""

Assuming that your text boxes are named txtJudge1 through txtJudge6, then I would do the following:
Code:
intCount = 0
For Idx = 1 to 6
   If Len(Trim(Me!Controls("txtJudge" & Trim(Idx)))) > 0) Then
      intCount = intCount + 1
   End If
Next Idx


Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top