reposting the same abt printing counts

  • Thread starter Thread starter sheela
  • Start date Start date
S

sheela

Hi,
I have a report based on a query. In the header section I
am printing the count of records in the report (query
output). For that I am
using countof(autonumberfield) in the query.
If the count is >0 , this works okay. But if there are no
records in the query results, then the count is being
prited as: "#Error". How do i print this as 0?
Is there another way to print the count of records in a
report?

TIA.
Sheela.
 
sheela said:
I have a report based on a query. In the header section I
am printing the count of records in the report (query
output). For that I am
using countof(autonumberfield) in the query.
If the count is >0 , this works okay. But if there are no
records in the query results, then the count is being
prited as: "#Error". How do i print this as 0?
Is there another way to print the count of records in a
report?


Try this:
=IIf(Report.HasData, Count(*), 0)


Notes:

Count(*) is fasterthan Count(keyfield).

Count(field) will not count records where field has a Null
value, while Count(*) counts all records regardless of the
values in any field.
 
It worked, thank you.
-----Original Message-----



Try this:
=IIf(Report.HasData, Count(*), 0)


Notes:

Count(*) is fasterthan Count(keyfield).

Count(field) will not count records where field has a Null
value, while Count(*) counts all records regardless of the
values in any field.
 
Back
Top