Count number of items in a listbox

  • Thread starter Thread starter BZeyger
  • Start date Start date
B

BZeyger

Hello,

I am new to Access. I have a form with a list box named lstProject that gets
it data from a table (table_Project). The list box works fine. It shows all
of my desired results. I would like to place a textbox (txtCount) underneath
the listbox to count how many records appear in the list box.

Is there an easy way to do this? I was not sure what code I would need to
put in.
 
BZeyger said:
Hello,

I am new to Access. I have a form with a list box named lstProject that
gets
it data from a table (table_Project). The list box works fine. It shows
all
of my desired results. I would like to place a textbox (txtCount)
underneath
the listbox to count how many records appear in the list box.

Is there an easy way to do this? I was not sure what code I would need to
put in.


Set your text box's ControlSource property to:

=[lstProjects].[ListCount]
 
Take a look at Access HELP for .Count, a property of a listbox. One
possibility would be to add an unbound textbox and set its Control Source to
something like (untested):

=Me!YourListboxName.Count

Regards

Jeff Boyce
Microsoft Access MVP
 
Jeff Boyce said:
oops! my bad. use .ListCount, not .Count ...

Jeff


Don't use "Me", either. :-) You could use "Form":

=Form!YourListboxName.ListCount

.... but that's redundant, and you can just use:

=YourListboxName.ListCount
 
Back
Top