Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

9.20 Tutorial 9-7 Putting Subreports in Separate Sections

Tutorial 9-7. Putting Subreports in Separate Sections

In this tutorial, we will examine the first two rules mentioned above and demonstrate why each subreport should be put in its own section.

  1. Open the report ‘Customer Net Sales.rpt’.
  2. The first rule we want to test is whether formulas in the subreport get calculated after the formulas in the main report. If you recall, I recommended that subreports always be put in their own sections to prevent this from happening. In this report, the subreport is already in a different section than the Net Sales formula (that is why the totals work properly). Let’s experiment and see what would have happened if we didn’t follow that rule.
  3. In design mode, find the Net Sales formula and move it from Group Footer #1b into the bottom of the section right above it, Group Footer #1a. Notice that this is the same section the subreport is in (and will probably cause problems). Preview the report to see what the result is.


  1. Now that the Net Sales formula is in the same section as the subreport, it has the same value as the total sales figure. This is because the shared value in the subreport hasn’t been calculated yet and it is zero. Thus, the credits aren’t being subtracted from the total sales. This proves that the main report’s formula has to be in a separate section to be calculated properly.

Another interesting consequence of not following this rule is that the following Net Sales calculations will use the previous Net Credits value. Since the subreport wasn’t calculated yet in that section, the current value of the TotalCredits shared variable will be what was calculated for the previous customer. This makes all the Net Credits amounts to appear to be one-off.

  1. Don’t save the changes to this report. Since the data is bad, simply close the report without saving.