Count number of items in a listbox

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.
 
D

Dirk Goldgar

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]
 
J

Jeff Boyce

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
 
D

Dirk Goldgar

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
 

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