Link to home
Start Free TrialLog in
Avatar of Gordon Hughes
Gordon HughesFlag for United Kingdom of Great Britain and Northern Ireland

asked on

How to total a sub report

I have a report with a sub report for Labour Hours
With a @Sum of @Labour_Hrs
I have created a shared formula in the sub report
@DECVAL
WhilePrintingRecords;
Shared numberVar BudgetValue ;
BudgetValue

in the main report have also created @DECVAL
WhilePrintingRecords;
Shared NumberVar Hours := 0;

Have created a formla in the main report @Labour Hours
WhilePrintingRecords;
Shared NumberVar Hours := 0;

The main report has a group called @Equiplocation
I would like to sum the @Labour Hours on the main report in both the @Equiplocation group and footer

Gordon
Avatar of James0628
James0628

I'm a bit confused.  You say that you want a sum of "@Labour Hours", but you say that the subreport has a formula that declares a variable named BudgetValue, and doesn't put anything in that variable.  Also, you say that in the main report you have a formula named @DECVAL and a formula named @Labour Hours, and they're exactly the same (they both set Hours to 0).  Do you really have two formulas in the main report that do the same thing?

 Basically, if you have a value in a subreport that you want to use in the main report, you put that value in a shared variable in the subreport, and then use that shared variable in the main report, in a formula that's located in a section that comes after the section that the subreport is in.  If you want to add a total from the subreport, you can have a formula add each amount to the variable.  For example, in a subreport detail section you might have a formula with a line like Hours := Hours + {some field}.  Or, in the subreport report header or footer, you might have a formula with a line like Hours := Sum ({some field}), to put the total from the subreport in the variable.

 If you're trying to get a total for a group in the main report, you would put a formula in the group header in the main report that reset the variable to 0 for each new group.

 Without knowing more about your report and exactly what you're trying to do, it's hard to be specific.

 James
Avatar of Gordon Hughes

ASKER

Hi James
Good to hear from you
The sub report DECVAL is
shared numbervar Hours;

if isnull (Sum ({@Labour_Hrs})) then Hours:=0.00 else
Hours:= Sum ({@Labour_Hrs})
 not the one I intially sent

Gordon
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
As usual a working solution