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!

passing a value from subreport to main report for calculation. 2

Status
Not open for further replies.

nghiemTran

Programmer
Mar 3, 2010
4
US
Hello,
I would like to use the result from the subreport
to main report for calculation.
Ex: subreport field1 is 100; and main report field2 is
500; would like to have in the main report
field2 - field1 should get the result of 400.
Really appreciate any solutions from you.

Thanks in advance,
Nghiem
 
You have to set up the subreport value as a shared varaible:

whileprintingrecords;
shared numbervar x := {sub.value};

In the main report, in a section after the one containing the subreport, e.g., GH1b if the sub is in GH1a, use a formula like this;

whileprintingrecords;
shared numbervar x;
{main.field} - x

You should also have a reset formula in the report header and in the section following the one where you do the calculation, e.g,, GH1c in this example or in GF1:

whileprintingrecords;
shared numbervar x := 0;

-LB
 
Dear -LB
I don't understand the last section of your solution,I did the first & second part & it works but in my main report,shared value didn't add with another values of main report.Would you help me please?
Thanks
 
Please explain in what report section your sub is located and also in what report section you have placed each formula. It might help to show the formulas. Also show the formula you set up in the subreport to share the variable and explain where it is located in the sub.

-LB
 
OK,Crystal Report8.5,SQL Server2005,main report is a stored procedure report and because of it i joined an Access dbs with subreport.note that the shared value is from Access dbs.Main rpt has two group,i placed sub in GH2A,shared value in detailes,reset formula in rpt header,shared value in sub in detailes.
shared value formula in sub:
whileprintingrecords;
shared numbervar x := {Sheet2.ID};
shared value formula in main rpt:
whileprintingrecords;
shared numbervar x;
reset formula:
whileprintingrecords;
shared numbervar x := 0;
also i want to write a select-case formula for shared value & add it with other values in main.
Thanks a lot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top