View Single Post
  #5  
Old March 1st, 2008, 01: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