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  

COUNT expression in a report



 
 
Thread Tools Display Modes
  #1  
Old March 1st, 2008, 12:01 AM posted to microsoft.public.access
Trying
external usenet poster
 
Posts: 49
Default COUNT expression in a report

Hi
I have a field, named [Type].
In a report, what is the expression to count this field “[Type]” where
Type="Truck"
??? =Count([Type]) where type = “Truck”
Thanks



  #2  
Old March 1st, 2008, 12:23 AM posted to microsoft.public.access
Steve Schapel
external usenet poster
 
Posts: 1,422
Default COUNT expression in a report

Trying,

In the Control Source of an unbound textbox in the Footer or Header of
the report...

=Sum(IIf([Type]="Truck",1,0))

--
Steve Schapel, Microsoft Access MVP

Trying wrote:
Hi
I have a field, named [Type].
In a report, what is the expression to count this field [Type] where
Type="Truck"
??? =Count([Type]) where type = Truck
Thanks



  #3  
Old March 1st, 2008, 01:57 AM posted to microsoft.public.access
Trying
external usenet poster
 
Posts: 49
Default COUNT expression in a report

Steve
I used your expression in an unbound text box in the footer of my report.
An error window poped up saying.....The expression
=Sum(IIf([Type]="Truck",1,0)) is invalid. Aggregate functions are only
allowed on output fields of the Record Source.
Any suggestions?



"Steve Schapel" wrote:

Trying,

In the Control Source of an unbound textbox in the Footer or Header of
the report...

=Sum(IIf([Type]="Truck",1,0))

--
Steve Schapel, Microsoft Access MVP

Trying wrote:
Hi
I have a field, named [Type].
In a report, what is the expression to count this field “[Type]” where
Type="Truck"
??? =Count([Type]) where type = “Truck”
Thanks




  #4  
Old March 1st, 2008, 02:18 AM posted to microsoft.public.access
Steve Schapel
external usenet poster
 
Posts: 1,422
Default COUNT expression in a report

Trying,

It sounds like the [Type] field is not included in the query that the
form is based on. It needs to be.

--
Steve Schapel, Microsoft Access MVP

Trying wrote:
Steve
I used your expression in an unbound text box in the footer of my report.
An error window poped up saying.....The expression
=Sum(IIf([Type]="Truck",1,0)) is invalid. Aggregate functions are only
allowed on output fields of the Record Source.
Any suggestions?

  #5  
Old March 1st, 2008, 02:52 AM posted to microsoft.public.access
fredg
external usenet poster
 
Posts: 4,386
Default COUNT expression in a report

On Fri, 29 Feb 2008 16:57:01 -0800, Trying wrote:

Steve
I used your expression in an unbound text box in the footer of my report.
An error window poped up saying.....The expression
=Sum(IIf([Type]="Truck",1,0)) is invalid. Aggregate functions are only
allowed on output fields of the Record Source.
Any suggestions?

"Steve Schapel" wrote:

Trying,

In the Control Source of an unbound textbox in the Footer or Header of
the report...

=Sum(IIf([Type]="Truck",1,0))

--
Steve Schapel, Microsoft Access MVP

Trying wrote:
Hi
I have a field, named [Type].
In a report, what is the expression to count this field [Type] where
Type="Truck"
??? =Count([Type]) where type = Truck
Thanks



You asked this same question a couple of days ago and received the
same answer from me that Steve gave you today. If you ask the question
again tomorrow you'll get the same answer you did today.

Evidently the reason it's not working for you is that you left out of
your message the important part about your placing this control in the
footer of the report.
I would suspect you placed it in the Page Footer.
You cannot do calculations in the Page Footer section of a report.

Place the control, with the above expression, in the detail section.
Then in the Page Footer refer to that control:
=[NameOfControlInDetailSection]

Don't forget to not use the reserved word 'Type' as a field name. It's
going to 'bite' you in the future if you do.

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
 




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 12:14 AM.


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