subreport with no data

rdw456

Novice
Local time
Today, 13:50
Joined
Jul 20, 2012
Messages
43
Hi all

I have a report with five subreports and each one has a total which is used in a calculation in the main report. When any of the subreports has no data I get an error on the main form.

Thanks Bob
 
I will assume your question is:

How to write the calculation so it can handle a sub report with no data?

How are you referencing (getting) the data from the sub report to the main report?

One possible solution is to add five HIDDEN (visible = false) text boxes to the main report.

Method 1: HasData property
Each text will hold the total for one sub report by using a control source similar to:

control: txtSub1Total
Code:
=IIf([Sub1].[Report].[HasData], Nz([Sub1].[Report].[txtTotal], 0), 0)

Methid 2: IsError() function

Example:

control: txtSub1Total
Code:
=IIf(IsError([Sub1].[Report].[txtTotal]), 0, Nz([Sub1].[Report].[txtTotal], 0))


Substituting with your control names for your reports.

You should then have five textbox controls all with valid data or Zero.

Now you can total the five controls without errors


Example:

Code:
=[txtSub1Total] + [txtSub2Total] + [txtSub3Total] + [txtSub3Total] + [txtSub5Total]
 
Thanks it pointed me in the right direction and made me change my approach
 
Glad we could assist.

Good luck with your project.
 

Users who are viewing this thread

Back
Top Bottom