subreport and null value problem

  • Thread starter Thread starter Tony
  • Start date Start date
T

Tony

I am having the problem: I have a "Count(*)" function in
the footer of a report, and within the function I've
included the "Nz[field],0" operator to show the 0 when no
records are present. When the report is viewed stand-
alone, it prints out fine. However, when it is included
as a subreport in another main report, it disappears when
the value is 0. How can I get that subreport to show up
even if the value is 0?

Any help would be greatly appreciated.
 
Tony said:
I am having the problem: I have a "Count(*)" function in
the footer of a report, and within the function I've
included the "Nz[field],0" operator to show the 0 when no
records are present. When the report is viewed stand-
alone, it prints out fine. However, when it is included
as a subreport in another main report, it disappears when
the value is 0. How can I get that subreport to show up
even if the value is 0?


A subreport with no records does not have any values, not
even Null. You can, however test if the subreport has data
or not and use that to make a control on the main report
visible of not. For example, if you have a label control
with the caption 0 on the main report in the same place as
the subreport control, then you can use a line of code:

Me.thelabel.Visible = Not Me.subreport.Report.HasData

to display the zero when there is nothing in the subreport.
 
Marsh,

I tried your suggestion below, but am a little confused
about the label control. When I go to the properties
dialog box for the label, there are no places to enter
events or control source. Where should I place the code

Me.thelabel.Visible = Not Me.subreport.Report.HasData

and/or how do I attach that code to the label?

I appreciate the help.

Tony
-----Original Message-----
Tony said:
I am having the problem: I have a "Count(*)" function in
the footer of a report, and within the function I've
included the "Nz[field],0" operator to show the 0 when no
records are present. When the report is viewed stand-
alone, it prints out fine. However, when it is included
as a subreport in another main report, it disappears when
the value is 0. How can I get that subreport to show up
even if the value is 0?


A subreport with no records does not have any values, not
even Null. You can, however test if the subreport has data
or not and use that to make a control on the main report
visible of not. For example, if you have a label control
with the caption 0 on the main report in the same place as
the subreport control, then you can use a line of code:

Me.thelabel.Visible = Not Me.subreport.Report.HasData

to display the zero when there is nothing in the subreport.
 
tony said:
I tried your suggestion below, but am a little confused
about the label control. When I go to the properties
dialog box for the label, there are no places to enter
events or control source. Where should I place the code

Me.thelabel.Visible = Not Me.subreport.Report.HasData

and/or how do I attach that code to the label?


Sorry, I should have said that the code needs to be in the
Format event of the **section** containing the subreport.

The code is not "attached" to the label, it just operates on
the label.
--
Marsh
MVP [MS Access]




-----Original Message-----
Tony said:
I am having the problem: I have a "Count(*)" function in
the footer of a report, and within the function I've
included the "Nz[field],0" operator to show the 0 when no
records are present. When the report is viewed stand-
alone, it prints out fine. However, when it is included
as a subreport in another main report, it disappears when
the value is 0. How can I get that subreport to show up
even if the value is 0?

Marshall BArton wrote
A subreport with no records does not have any values, not
even Null. You can, however test if the subreport has data
or not and use that to make a control on the main report
visible of not. For example, if you have a label control
with the caption 0 on the main report in the same place as
the subreport control, then you can use a line of code:

Me.thelabel.Visible = Not Me.subreport.Report.HasData

to display the zero when there is nothing in the
subreport.
 
Back
Top