Passing subreport value to mainreport crystal

crystal-reports

I have a report that contains a subreport. I am trying to get a value from the subreport into a field on my main report. My issue is it is not displaying on the correct report, but the report after and subsequent reports. So maybe I am not reset the var correctly.

Subreport header

whileprintingrecords;
shared numbervar amount := 0;

Subreport Footer

whileprintingrecords;
shared numbervar amount := {ap1.amount};

Mainreport formula field

shared numbervar amount;
amount;

I have the subreport in the details section ( also tried to put in report header – I am suppressing the report anyway ). Then in the details section I have the formula field which is displaying 0.00 on main report, but if I cycle through the report pages my desired value shows up on the report right after. I am linking my subreport and main report by contract no.

Any help is appreciated. Am I not declaring something right or do I need to set my shared amount to 0 somewhere?

Thanks

Best Answer

On the main report formula:

shared numbervar amount;
amount := amount;

Related Topic