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 » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Counting number of records based on criteria



 
 
Thread Tools Display Modes
  #1  
Old May 20th, 2010, 02:42 PM posted to microsoft.public.access
johan
external usenet poster
 
Posts: 40
Default Counting number of records based on criteria

Hello,

(Try again to get the question in the google-groups. Perhaps not
pushed on the send button).

For counting records as expression in a report in ms.access I'm using
=count(*) which shows all records.

Now I also want to know how many of them has registered a specific
data in a specific field.

I'm trying to use =count([Field1]="999") to count how many of the
selection reported has registered data 999.
This option isn't work. Can somebody give me the correct solution.

thanks,
Johan

  #2  
Old May 20th, 2010, 04:47 PM posted to microsoft.public.access
Jerry Whittle
external usenet poster
 
Posts: 4,732
Default Counting number of records based on criteria

The 999 needs to go in the criteria for the query driving the report or the
filter for the report.

You could also group by Field1 if you want to see the count for the various
data in Field1.

You could also use DCount in a text field which would look something like:

=DCount("[Field1]", "TheTableName", "[Field1] = '999'")

Note that DCount, or any of the aggregate functions starting with "D", can
be very slow when used like this.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


"johan" wrote:

Hello,

(Try again to get the question in the google-groups. Perhaps not
pushed on the send button).

For counting records as expression in a report in ms.access I'm using
=count(*) which shows all records.

Now I also want to know how many of them has registered a specific
data in a specific field.

I'm trying to use =count([Field1]="999") to count how many of the
selection reported has registered data 999.
This option isn't work. Can somebody give me the correct solution.

thanks,
Johan

  #3  
Old May 20th, 2010, 04:50 PM posted to microsoft.public.access
KenSheridan via AccessMonster.com
external usenet poster
 
Posts: 1,610
Default Counting number of records based on criteria

Either of these should do it:

=Sum(IIf([Field1]="999",1,0))

or:

=Count(IIf([Field1]="999",1,Null))

Ken Sheridan
Stafford, England

johan wrote:
Hello,

(Try again to get the question in the google-groups. Perhaps not
pushed on the send button).

For counting records as expression in a report in ms.access I'm using
=count(*) which shows all records.

Now I also want to know how many of them has registered a specific
data in a specific field.

I'm trying to use =count([Field1]="999") to count how many of the
selection reported has registered data 999.
This option isn't work. Can somebody give me the correct solution.

thanks,
Johan


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/201005/1

 




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:23 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.