reposting the same abt printing counts

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.
 
M

Marshall Barton

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.
 
S

sheela

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top