Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Summing shared Variables

Status
Not open for further replies.

slicknick515

Technical User
Aug 27, 2009
15
0
0
US
I have two subreports within the Details A section of main report.
Subreport 1 has a shared variable named MyTotal
Subreport 2 has two shared variables named MyTotal2 and MyTotal2a
On the main report, I have the formulas below->
@MainFormula
Whileprintingrecords;
Shared NumberVar myTotal;
myTotal

@MainFormula2
Whileprintingrecords;
Shared NumberVar myTotal2;
myTotal2

@MainFormula2a
Whileprintingrecords;
Shared NumberVar myTotal2a;
myTotal2a * -1

@Project1
{Current_Inventory} + {@MainFormula2} + {@MainFormula2a}

@Project2
{@MainFormula} - {@Project1}

(This is in my group footer and is working great)
@Cost
{Cost} * {@Project2}

The issue is that i want a Grand Total Cost...that is where I am lost!
Any suggestions?
 
Just to add, I tried to Insert a summary of {@Cost} but this formula isn't available to Sum.
I also tried to do the Sum formula but that field can't be summarized.
 
Also, I tried Summing the variables separately and then multiplying by the cost.
 
Why not just put the shared variables into the one formula:

@Project1
Whileprintingrecords;
Shared NumberVar myTotal;
Shared NumberVar myTotal2;
Shared NumberVar myTotal2a;

{Current_Inventory} + myTotal - myTotal2a


If you wnat to total that formula you need another variable. Global will be fine...

In the group header section
WhilePrintingRecords;
Global Numbervar GR1Total :=0

In the Details, or a section after your subreport
WhilePrintingRecords;
Global Numbervar GR1Total := GRTotal + {@Project}

In the Group Footer Section
WhilePrintingRecords;
Global Numbervar GR1Total

Similarly for the Grand Total, place the reset in the Report Header, and you can accumulate both totals in the Summing formula above.

Bruce Ferguson
 
Sorry, I may not be understanding where to put everything you posted above. Where would i place the first formula that contains the shared variables. Maybe it will be easier if i lay it out for you...

Group Header 1-> Clinic
Group Header 2-> Product
Details-> Contains both subreports referenced above.
Group Footer 2->Contains all of the shared variable values referenced above. All of the values look good. My Cost multiplied by @Project2 values are correct.
Group Footer1-> Suppressed

Basically, I want to be able to show a grand total SUM of the Cost times @Project2.

Thanks so much for your detailed response. I'm still learning shared variables and I don't completely understand them yet.
 
You need add another global variable


place this in your group footer
@costTotal
whileprintingrecords;

global numbervar costTot:=costTot+{@cost}

In report footer

@Display CostTotal
whileprintingrecords;

global numbervar costTot

Ian
 
Thanks IanWaterman and others for the help. The last suggestion worked great!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top