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

how to bring a vlue from sub-report to main report 2

Status
Not open for further replies.

maas

Programmer
Sep 3, 2009
148
BH
Hello All,

I placed a subreport in the group header #1 in the main report.
My aim is to bring a total of deals amount from a subreport and pass the total to the main report.

How can I pass the sum formula which is in the subreport in the main report and place it in group header #1 in the main report? And I want to use it with the other formulas in the main report?

How can I do this?

Thanks
 
To pass data back from a subreport, use a shared variable. For a date, put a formula field in the subreport like
Code:
Shared dateVar    
V_Today := {LoadStatus.LastDLoad}
To access it in the main report, create another formula field with
Code:
Shared dateVar 
V_Today := V_Today

If it was a currency value, you'd do it differently, e.g.
Code:
whileprintingrecords;
shared currencyvar SumSaved;
SumSaved:={#TotSaved};
SumSaved
And to access it in the main report, create another formula field with
Code:
whileprintingrecords;
shared currencyvar SumSaved;
SumSaved

Note that the shared variable is only available in the section after the section which contains the subreport.

The main-report field can be referenced normally in other formula fields.

It helps to give your Crystal version - 8, 8.5, 9, 10, 11 or whatever. Methods sometimes change between versions, and higher versions have extra options. In this case, it probably makes no difference.


[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 10 & 11.5 with Windows XP [yinyang]
 
Thanks Madwac for your help
the sum is integer, so I will use numbervar, correct me if I am worng and I will use your third and fourth formula?

So, how to show the total in the group header #1 in my case?

Thanks
 
Create a second section for the group header. The first section has the subreport and the second one shows it

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 10 & 11.5 with Windows XP [yinyang]
 
Hi Madawc,

If got the same issue here.
I have made a main report with groups per customer.
In every groupfooter I have got a subreport with a total.
I would like to use that total in a new section of that groupfooter. unforunately my result is 0.

Even if i use this:

whileprintingrecords;
shared currencyvar SumSaved;
SumSaved:=5
SumSaved

My result is not 5 but 0.
Any ideas?

Thanks!
Frank
 
If you have a new enquiry its best to start a new thread as some people might not bother to look at an old thread.

You have to make sure the Subreport executes first.

SR must be in upper section of your split group footer.

YOur display formula in main report must also be whileprintingrecords;

Ian

 
In addition, neither the subreport object or the section it is in can be suppressed or hidden.

-LB
 
Hi All,
I tried Madawc's formulas in my report but cannot get it to work. I am trying to pass a value from subreport to the main using Crystal 8.5. Should it work in 8.5 as well?
 
Yes. You need to tell us in what report section your sub is located, and in what sections you have placed the formulas. You should probably show us the content of the formulas, too.

-LB
 
I got it to work. My dilemma right now is suppressing the subreport. I do not want the subreport displayed nor the section it is in but supressing it will not move the value to the variable. Do you have a workaround? I currently have the subreport in GF#1a and the variable in GF#1b.
 
In 8.5 it's harder to make subs disappear and still pass shared variables. You can suppress all sections WITHIN the subreport and remove the borders, and then make the GH1a section small. Then in the section expert, format GF1a to "underlay following sections".

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top