Count

J

Jini

I am using a count. If there is no records, I get an error
message #error instead of 0. Is there a way to make the
count show 0 if no records were found to count?
 
B

Bill Crawford

Hi:

Use this function in your report's [Fieldname] control source or query
[Fieldname] criteria

IIF(Count([Fieldname])is null,0,Count([Fieldname]))
 
D

Duane Hookom

I don't think this will work.
Try:
=IIf([HasData],Count(*),0)

--
Duane Hookom
MS Access MVP


Bill Crawford said:
Hi:

Use this function in your report's [Fieldname] control source or query
[Fieldname] criteria

IIF(Count([Fieldname])is null,0,Count([Fieldname]))

Jini said:
I am using a count. If there is no records, I get an error
message #error instead of 0. Is there a way to make the
count show 0 if no records were found to count?
 
M

Marshall Barton

Jini said:
I am using a count. If there is no records, I get an error
message #error instead of 0. Is there a way to make the
count show 0 if no records were found to count?

How are you using the Count? If a report has no records,
then there is nothing in the report and a count doesn't make
much sense.

If the count is in a subreport and you want to display the
count in the n=main report then use an expression like:

=IIf(subreport.Report.HasData, subreport.Report.txtcount, 0)
 
Top