R
Robert
I have a report with two sub reports that I’m trying to do some basic math
with. After researching for a solution I thought I found a solution.
Stage 1
If the subreport is called Sub1, and the text box is txtTotal, put the text
box on your main report, and start with this Control Source:
=[Sub1].[Report].[txtTotal]
Stage 2
Check that it works. It should do if there are records in the subreport. If
not, you get #Error. To avoid that, test the HasData property, like this:
=IIf([Sub1].[Report].[HasData], [Sub1].[Report].[txtTotal], 0)
Stage 3
The subreport total could be Null, so you might like to use Nz() to convert
that case to zero also:
=IIf([Sub1].[Report].[HasData], Nz([Sub1].[Report].[txtTotal], 0), 0)
The problem I have is I get #error messages when no sub report exists. If a
subreport does exist things work fine. I have tried both the hasdata and NZ
in steps 2 and 3 with no luck. The only difference I have found is I’m using
! Between fields not a . When I use a . I get name error. Again data is
pulling from subreports if they exist so I know the location is fine. Any
help would be appreciated.
with. After researching for a solution I thought I found a solution.
Stage 1
If the subreport is called Sub1, and the text box is txtTotal, put the text
box on your main report, and start with this Control Source:
=[Sub1].[Report].[txtTotal]
Stage 2
Check that it works. It should do if there are records in the subreport. If
not, you get #Error. To avoid that, test the HasData property, like this:
=IIf([Sub1].[Report].[HasData], [Sub1].[Report].[txtTotal], 0)
Stage 3
The subreport total could be Null, so you might like to use Nz() to convert
that case to zero also:
=IIf([Sub1].[Report].[HasData], Nz([Sub1].[Report].[txtTotal], 0), 0)
The problem I have is I get #error messages when no sub report exists. If a
subreport does exist things work fine. I have tried both the hasdata and NZ
in steps 2 and 3 with no luck. The only difference I have found is I’m using
! Between fields not a . When I use a . I get name error. Again data is
pulling from subreports if they exist so I know the location is fine. Any
help would be appreciated.