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

Get data from subreport?

Status
Not open for further replies.

goldyr

Programmer
May 26, 2003
25
SE
I want to get data from a field in a subreport into the main report. Can I do that? I need to have the field in a summary.

 
You can pass values from the subreport into the main report by storing the value in a shared variable, and calling the shared variable in the main report.

Naith
 
There is a lot of shared variable information in your online help in Crystal Reports.

Essentially, you will be creating one formula in your subreport, like:

//@Populate The Variable
WhilePrintingRecords;
Shared NumberVar XXX := {YourField};

and another one in your main report - which is placed in a section after your subreport:

//@Call The Variable
WhilePrintingRecords;
Shared NumberVar XXX;

If you want to accumulate the value of the variable in the main report so that you can get a grand total going, then you would use a formula like this one:

//@Add Up Each Occurence Of The Variable
WhilePrintingRecords;
NumberVar YYY;
Shared NumberVar XXX;

YYY := YYY + XXX;

You would have to place a formula like the last one in a B section of wherever the subreport is placed. For example, if the subreport is situated in Group Footer 1a, then you place the formula in Group Footer 1b.

Naith
 
Thanks, this work but I have to redesign my report then, because I have the summary field and the subreport in the same section. Or is it another way to do it?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top