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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding formulas from Subreport to Main Report

Status
Not open for further replies.

debbiepy

MIS
Jan 19, 2005
43
US
I have a sub report that is linked by sales agent to main report. In this sub report I have a formula to calculate the value of each sale. I want to add this value to the group total in the main report. Can I do this?
 
yes - store the value in the subreport in a shared variable like:

shared numbervar subtotal := {value]

Then in a formula in the Main report use the variable:

shared numbervar subtotal

Both the main report and the subreport can see and change a shared variable.

Cheers
paulmarr
 

I created a Formula Field in the subreport named TtlOBShare and put this in it--- (this sums the shares for each employee)


shared numbervar TtlOBShare :=
Sum ({@OBsharePay}, {Employee_List.First_Name})

Then in the main report for each employee I put this in a Formula field named TtlHybrid---

um ({@ReducedSale}, {Employee_List.First_Name}) +
shared numbervar TtlOBShare;

Results it did not add the ttlobshare to the main report. What did I do wrong?

 
shared numbervar TtlOBShare;

TltOBShare + Sum ({@ReducedSale}, {Employee_List.First_Name})


Make sure that this formula in the main report is below the subreport or this formula will process before the subreport has had a chance to fetch the value.

I hope this helps

paulmarr
 
Thank you again. That did not work. I am new to this version of CR (9.) Last time I used CR was back in 97!

I may have my subreport in the wrong place. I put the sub report in the group footer 3 (first name) and my shared formula in group footer 2, then 1, neither worked. Then I put my subreport in the header and the shared in the footer and still didn't work.

Am I suppose to create the shared variable in the Formula Editor of the sub report, that is what I did and I called the shared variable the same as the formula name.
 
Try this:

Create a formula called initialise and just put:
shared numbervar TtlOBShare := 0;

Put this formula in the group header of the main report and supress it.

I didn't ask but I assume your subreport is not an on demand subreport? It can't be on demand.

It will have something to do with where you place the subreport and the formula in the main report.
 
Be sure to place the shared variable formula in the subreport somewhere on the subreport. Also, the placement of your subreport depends upon your links. If you are linking on name, then the subreport belongs in the name group header or footer--doesn't matter which. Then insert another section to this group header or footer, and place the calculation using the shared variable in that GH_b or GF_b section.

-LB
 
Thank you both for the help. I did get it to work (accidentally) but had to re arrange the totals to be in the footer instead of the employee header. But, at least it works! Thank you so much.

Debbie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top