COUNT expression in a report

S

Steve Schapel

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
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
 
T

Trying

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 said:
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
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
 
S

Steve Schapel

Trying,

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

fredg

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 said:
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
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.
 
Top