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!

List Box conditional count 1

Status
Not open for further replies.

dendic

Programmer
Jan 19, 2003
106
US
I have a list box with three columns Name,Department,Salary. I use the listcount to get a count of all the records. But is there a method to count just the records within the listbox where department = 1 for example
 
Something like:

Private Sub List7_DblClick(Cancel As Integer)
Dim listrs As Integer
Dim listsum As Integer
listrs = Me![List7].ListCount
x = 1
Do
If Me![List7].Column(2,x) = 1 Then
listsum = listsum + 1
x = x + 1
Else
x= x+1
End IF
Loop Until x = listrs
Me![Text9].Value = listsum
End Sub

You can highlight Column and hit the F1 to see examples of the property.
The Column property starts (column,row) at 0.
This code assumes column headers thus x = 1.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top