ListCount

F

FrankC

I use the ListCount property to let the user know how big the list is. Is
there a similar property that indicates how many items are selected in a list
(extended select)? I want to show the user a running total as he/she
selects items. I also want to put a limit on how many items can be selected.
Thanks


PS: Minor point. When I use ListCount, it gives a number that is always 1
more than the number of items in the list. Am I doing something wrong?
 
D

Douglas J. Steele

Me!MyListbox.ItemsSelected.Count

As to your question about ListCount, the Help file says "If you set the
ColumnHeads property to Yes, the row of column headings is included in the
number of rows returned by the ListCount property. For combo boxes and list
boxes based on a table or query, adding column headings adds an additional
row. For combo boxes and list boxes based on a value list, adding column
headings leaves the number of rows unchanged (the first row of values
becomes the column headings)." Might that be your issue? Since the list
box's ColumnHeads property will be -1 when it's active, you can use
(Me!MyListbox.ListCount + Me!MyListbox.ColumnHeads) to get an accurate
count.
 
J

John W. Vinson

I use the ListCount property to let the user know how big the list is. Is
there a similar property that indicates how many items are selected in a list
(extended select)? I want to show the user a running total as he/she
selects items. I also want to put a limit on how many items can be selected.
Thanks

For a multiselect listbox...

Me!listbox.ItemsSelected.Count

PS: Minor point. When I use ListCount, it gives a number that is always 1
more than the number of items in the list. Am I doing something wrong?

It's probably counting the header row.
 

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