A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

counting the number of records in a list box



 
 
Thread Tools Display Modes
  #1  
Old March 18th, 2009, 05:27 PM posted to microsoft.public.access.forms,microsoft.public.access.formscoding
Paul
external usenet poster
 
Posts: 126
Default counting the number of records in a list box

What expression can I use as the Control Source of a text box in the detail
section of a form to count the number of records in a list box?

I have a form named frm_list_project with a list box named List2. I'd like
to have a text box in the detail section at the top of the form that
displays the number of records in the list box. I've looked in Help and
tried various things like Me!List2.RecordCount but get messages like "Object
doesn't support that property."

What expression can I use to display the number of records?

Thanks in advance,

Paul


  #2  
Old March 18th, 2009, 05:38 PM posted to microsoft.public.access.forms,microsoft.public.access.formscoding
Damon Heron[_3_]
external usenet poster
 
Posts: 257
Default counting the number of records in a list box

Just
=[lstBoxName].[listcount]

Damon

"Paul" wrote in message
...
What expression can I use as the Control Source of a text box in the
detail section of a form to count the number of records in a list box?

I have a form named frm_list_project with a list box named List2. I'd
like to have a text box in the detail section at the top of the form that
displays the number of records in the list box. I've looked in Help and
tried various things like Me!List2.RecordCount but get messages like
"Object doesn't support that property."

What expression can I use to display the number of records?

Thanks in advance,

Paul



  #3  
Old March 18th, 2009, 05:45 PM posted to microsoft.public.access.forms,microsoft.public.access.formscoding
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default counting the number of records in a list box

If your list box uses a select statement why not copy, edit to a totals query
and use that.
--
KARL DEWEY
Build a little - Test a little


"Paul" wrote:

What expression can I use as the Control Source of a text box in the detail
section of a form to count the number of records in a list box?

I have a form named frm_list_project with a list box named List2. I'd like
to have a text box in the detail section at the top of the form that
displays the number of records in the list box. I've looked in Help and
tried various things like Me!List2.RecordCount but get messages like "Object
doesn't support that property."

What expression can I use to display the number of records?

Thanks in advance,

Paul



  #4  
Old March 18th, 2009, 08:44 PM posted to microsoft.public.access.forms,microsoft.public.access.formscoding
Paul
external usenet poster
 
Posts: 126
Default counting the number of records in a list box

Works great. Thanks, Damon.


  #5  
Old March 18th, 2009, 08:51 PM posted to microsoft.public.access.forms,microsoft.public.access.formscoding
Paul
external usenet poster
 
Posts: 126
Default counting the number of records in a list box

Interesting suggestion, Karl, but then Access has to run the query twice, so
I would guess it might be easier for it to evaluate the ListCount property.

However, I might be able to use your idea in a different form, so I tried it
out, but I got a displayed value of "#Name?" if I simply put the SELECT
statement into the Control Source property of a Text Box. I then tried
preceding the SELECT statement with an equal sign, but it wouldn't take
that.

Can you tell me what syntax to use to get the text box to display the result
of that total query?

Thanks


  #6  
Old March 18th, 2009, 11:43 PM posted to microsoft.public.access.forms
CrazyAccessProgrammer
external usenet poster
 
Posts: 58
Default listbox count

MyObject.ListCount - Abs(MyObject.ColumnHeads)

this code takes into account if you have headers in your listbox and if so,
subtracts 1 so as to NOT count the header row.
  #7  
Old March 19th, 2009, 01:18 AM posted to microsoft.public.access.forms
Paul
external usenet poster
 
Posts: 126
Default listbox count

Thanks for the suggestion, crazyaccessprogrammer.

In this case, I'm not using column headers, but this will be helpful for a
situation where I do use them.


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:26 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.