counting the list box

J

JohnE

I have a form and on it has a list box (list1) and a
combobox (combo1) that shows the years. When I select the
year, the list box displays the claims for the year
selected in the combo box. What I would like to do is use
a label (or textbox) and show how many items there are in
the listbox for the selected year. And I'm stumped.
Anyone have thoughts on this?
Thanks for the help.
*** John
 
K

Kevin S.

This should be easy to use... just set the control source or value to this..
you will need to edit it a bit

DCount ("[YearFieldName]","tablename","[YearFieldName]=" & [SelectedYear])

-Kevin
 
D

Dirk Goldgar

JohnE said:
I have a form and on it has a list box (list1) and a
combobox (combo1) that shows the years. When I select the
year, the list box displays the claims for the year
selected in the combo box. What I would like to do is use
a label (or textbox) and show how many items there are in
the listbox for the selected year. And I'm stumped.
Anyone have thoughts on this?
Thanks for the help.
*** John

I guess you either requery the list box or reset its rowsource to get it
to pick up the claims for the specified year. Once you've done that,
the list box control's ListCount property has the number of items in the
list. So you could set a label caption or an unbound text box's value
to List1.ListCount. For example,

Me.lblClaimCount.Caption = List1.ListCount & " claims"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top