show zero figure for count of records in report?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I imagine this may have a simple answer but i'm stumped. I have a report
that does a count of records - how do i get it to show a zero (0) if there
are no records for that area?

thanks for all the help!

Cheers
Laurene
 
Presumably you have a text box in the Report Footer section, and its Control
Source is:
=Count("*")

Try:
=IIf([Report].[HasData], Count("*"), 0)
 
My count is actually coming from the query - would i use the same in the
criteria for the field that is being counted?



Allen Browne said:
Presumably you have a text box in the Report Footer section, and its Control
Source is:
=Count("*")

Try:
=IIf([Report].[HasData], Count("*"), 0)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

triplespiral said:
I imagine this may have a simple answer but i'm stumped. I have a report
that does a count of records - how do i get it to show a zero (0) if there
are no records for that area?

thanks for all the help!

Cheers
Laurene
 
Yes, the idea is to test the HasData property of the report.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

triplespiral said:
My count is actually coming from the query - would i use the same in the
criteria for the field that is being counted?



Allen Browne said:
Presumably you have a text box in the Report Footer section, and its
Control
Source is:
=Count("*")

Try:
=IIf([Report].[HasData], Count("*"), 0)

triplespiral said:
I imagine this may have a simple answer but i'm stumped. I have a
report
that does a count of records - how do i get it to show a zero (0) if
there
are no records for that area?
 
Appreciate the help though I'm still a bit lost. maybe a bit more info will
help.

I have a query that had two fields, one the type of info (A or B) which is
"Group By" and then the second field is the ID number which i have set to
"Total" so currently the query is displaying only
A - 200

where i would like the query (and ultimately) the report to display
A - 200
B - 0

I understand your original advice if i was using a normal count on a report
- however the report fields are not count(*) as they are the actual field
"CountOf..." so I'm a bit unclear as to how and what to modify

Thanks for your patience!! :)

L.


Allen Browne said:
Yes, the idea is to test the HasData property of the report.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

triplespiral said:
My count is actually coming from the query - would i use the same in the
criteria for the field that is being counted?



Allen Browne said:
Presumably you have a text box in the Report Footer section, and its
Control
Source is:
=Count("*")

Try:
=IIf([Report].[HasData], Count("*"), 0)

I imagine this may have a simple answer but i'm stumped. I have a
report
that does a count of records - how do i get it to show a zero (0) if
there
are no records for that area?
 
So the query does not generate any record for the B type when there is no B?
It is therefore the query that needs work, not the report. An outer join
should solve the problem.

Your table has a lookup field for TypeOfInfo. You probably have a table that
contains the valid choices, so you can use a combo and ensure the user does
not enter an invalid choice. If you do not have such a table, create one. It
just needs one field of type Text, size 1, and marked as primary key. You
will then create a relationship between this lookup table and your main one
(Relationships on the Tools menu.)

Now add the lookup table to your query. You will see a line joining the 2
tables in the upper pane of query design. Double-click this line. Access
pops up a dialog offering 3 choices. Choose the one that says, "All records
from the little lookup table, and any matches from the main table you always
had."

The query will not show both the A and the B, even for the cases where the B
does not exist. It knows about the B value because it is in the lookup
table, even it if it is not in the main table.

If you have criteria on the main table, you will need to change these to
include the case there there is no match. Otherwise you lose the B again.
For example, if you have critiera of:
"USA"
change it to:
Is Null Or "USA"

More info on outer joins and criteria in this article:
The Query Lost My Records!
at:
http://allenbrowne.com/casu-02.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

triplespiral said:
Appreciate the help though I'm still a bit lost. maybe a bit more info
will
help.

I have a query that had two fields, one the type of info (A or B) which is
"Group By" and then the second field is the ID number which i have set to
"Total" so currently the query is displaying only
A - 200

where i would like the query (and ultimately) the report to display
A - 200
B - 0

I understand your original advice if i was using a normal count on a
report
- however the report fields are not count(*) as they are the actual field
"CountOf..." so I'm a bit unclear as to how and what to modify

Thanks for your patience!! :)

L.


Allen Browne said:
Yes, the idea is to test the HasData property of the report.

triplespiral said:
My count is actually coming from the query - would i use the same in
the
criteria for the field that is being counted?



:

Presumably you have a text box in the Report Footer section, and its
Control
Source is:
=Count("*")

Try:
=IIf([Report].[HasData], Count("*"), 0)

message
I imagine this may have a simple answer but i'm stumped. I have a
report
that does a count of records - how do i get it to show a zero (0) if
there
are no records for that area?
 
thank you!! I've followed your instructions and zeros are now appearing in
the query and report (hurrah! thank you thank you!)

However, one little snag? for some reason B Type is not displaying? so it
looks similiar to
A 200
(blank) 0

any ideas?

Thanks again!!

Laurene

Allen Browne said:
So the query does not generate any record for the B type when there is no B?
It is therefore the query that needs work, not the report. An outer join
should solve the problem.

Your table has a lookup field for TypeOfInfo. You probably have a table that
contains the valid choices, so you can use a combo and ensure the user does
not enter an invalid choice. If you do not have such a table, create one. It
just needs one field of type Text, size 1, and marked as primary key. You
will then create a relationship between this lookup table and your main one
(Relationships on the Tools menu.)

Now add the lookup table to your query. You will see a line joining the 2
tables in the upper pane of query design. Double-click this line. Access
pops up a dialog offering 3 choices. Choose the one that says, "All records
from the little lookup table, and any matches from the main table you always
had."

The query will not show both the A and the B, even for the cases where the B
does not exist. It knows about the B value because it is in the lookup
table, even it if it is not in the main table.

If you have criteria on the main table, you will need to change these to
include the case there there is no match. Otherwise you lose the B again.
For example, if you have critiera of:
"USA"
change it to:
Is Null Or "USA"

More info on outer joins and criteria in this article:
The Query Lost My Records!
at:
http://allenbrowne.com/casu-02.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

triplespiral said:
Appreciate the help though I'm still a bit lost. maybe a bit more info
will
help.

I have a query that had two fields, one the type of info (A or B) which is
"Group By" and then the second field is the ID number which i have set to
"Total" so currently the query is displaying only
A - 200

where i would like the query (and ultimately) the report to display
A - 200
B - 0

I understand your original advice if i was using a normal count on a
report
- however the report fields are not count(*) as they are the actual field
"CountOf..." so I'm a bit unclear as to how and what to modify

Thanks for your patience!! :)

L.


Allen Browne said:
Yes, the idea is to test the HasData property of the report.

My count is actually coming from the query - would i use the same in
the
criteria for the field that is being counted?



:

Presumably you have a text box in the Report Footer section, and its
Control
Source is:
=Count("*")

Try:
=IIf([Report].[HasData], Count("*"), 0)

message
I imagine this may have a simple answer but i'm stumped. I have a
report
that does a count of records - how do i get it to show a zero (0) if
there
are no records for that area?
 
Your query is reading the Type field from the original table.
Change it to the field from the new lookup table.
 
*smacks head* I should have known that.

Thank you so very very much. This one little tweak has been a thorn in my
side for ages.

Best,
L.
 

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

Back
Top