# Error when no data

  • Thread starter Thread starter Hank
  • Start date Start date
H

Hank

I have a report "DepositSummary" with a subreport "DepositGifts". The
subreport is from a report with the same name.

On each report is a text box for the grand total collected They are::"=Sum(Total
Deposit) and "=Sum(DepositGifts)". The report is opened by a daterange
form. Start date and end date is entered on the form.



When the subreport was added to the main report a grand total text box was
added "=([TutionTotal])+(DepositGifts!giftstotal). Each one is named after
the "name" of the text box and not the control source.



Good news -- The report work great!



Bad news --- It only works great then there is data in the daterange.



I have not been able to come up with the right code to put in each of the
text boxes to show 0 (zero) when no data is found so that it will still
calculate a grand total and show the report and subreport. # Error is shown
when there is no data.



I have tried these and several other variations with no luck:



=IIf([Total Deposit].[DepositSummary].[HasData]=True,=Sum[Total
eposit],0) - there is a space between 'Total Deposit'



=IIF(Total Deposit.DepositSummary.hasData=True,Sum(Total Deposit),0)





The code is going in the text box control source of the report and sub
report. I am still getting '# Error' or '# Name' with the code I have
tried.



Can some one get me on the right track?



Thanks

Hank
 
The generic syntax is something like:

=IIf([subrptName].[Report].[HasData]=True,[subrptName].[Report].CtrlOnSubreport ,0)
 
The generic syntax is something like:

=IIf([subrptName].[Report].[HasData]=True,[subrptName].[Report].CtrlOnSubreport ,0)
 
If the main report has a field named TotalDeposit, you want a text box in
the Report Footer section (not the page footer), with its ControlSource
property set to:
=IIf([Report].[HasData], Sum([TotalDeposit]), Null)

If the subreport has a field named DepositGifts, you want a similar
expresion in the Control Source of its (not the main report's) Report Footer
section:
=IIf([Report].[HasData], Sum([DepositGifts]), Null)

If that text box is named txtSubtotal, you can then refer to it on the main
report like this:
=IIf([DepositGifts].[Report].[HasData],
[DepositGifts].[Report]![txtSubtotal], Null)
 
If the main report has a field named TotalDeposit, you want a text box in
the Report Footer section (not the page footer), with its ControlSource
property set to:
=IIf([Report].[HasData], Sum([TotalDeposit]), Null)

If the subreport has a field named DepositGifts, you want a similar
expresion in the Control Source of its (not the main report's) Report Footer
section:
=IIf([Report].[HasData], Sum([DepositGifts]), Null)

If that text box is named txtSubtotal, you can then refer to it on the main
report like this:
=IIf([DepositGifts].[Report].[HasData],
[DepositGifts].[Report]![txtSubtotal], Null)
 
Back
Top