cancel
Showing results for 
Search instead for 
Did you mean: 

Totaling 2 subreports

Former Member
0 Kudos

In Crystal 11 I have 2 sub reports containing totals.Is there a way to total both of those totals and place in main report?

DZ

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

You will need to create shared variables from each sub-report and then formulas in the main report to add them.

sub-report 1

create a formula with the following:

whileprintingrecords;

shared numbervar numberone := sum({table.field})

sub-report 2

create a formula with the following:

whileprintingrecords;

shared numbervar numbertwo := sum({table.field})

Main report

sub-report 1

create a formula with the following:

whileprintingrecords;

shared numbervar numberone;

shared numbervar numbertwo;

numberone+numbertwo

This is the bear bones of it.

Answers (1)

Answers (1)

Former Member
0 Kudos

declare shared variables in the resepective subreports to store the total. once you declare them then create two formulas in main report and assgin those shared variables to those formulas the syntax would be as follows

in subreport 1

First formula would be "initval", here u declare a shared variable and keep in page header, so that it will be initated to 0 each time

initval (syntax is as follows)

shared numbervar tot1 :=0;

second formula is for "total1"

syntax for this formula would be as follows

shared numbervar tot1 := shared numbervar tot1 + table1.amount (this is field which u want the total)

in subreport 2

formula one would be again "initval" here u declare a shared variable and keep in page header, so that it will be initated to 0 each time

initval (syntax is as follows)

shared numbervar tot2 :=0;

Second formula would be for "total2"

syntax for this formula would be as follows

shared numbervar tot2 := shared numbervar tot2 + table1.amount (this is field which u want the total)

now in main report

first formula is " totsub1"

syntax would be as follows

shared numbervar tot1;

second formula is " totsub2"

syntax would be as follows

shared numbervar tot2;

now you create one more formual for tot1+tot2

you will get total from both the sub report.

If u have any queires please get back to me.