0
votes

I am using Crystal Report, and I want to display the value of shared variable in Main Report that will change from Sub Report. I know, this is a very old topic, and there are solutions available on the internet and stackoverflow also.

Crystal Reports: How to pass a parameter from a subreport to the parent report?

http://www.ehow.com/how_5287432_use-shared-variable-crystal-report.html

I tried both solution but none of them is working. I am sure something I am missing. I am just started working on crystal report, so It could be little mistake.

What I tried?

I have created a formula in Main report named f_main and added

Shared NumberVar balance;
balance := 0;

Now I have dragged it on main report to see the output. Of Course output would be 0 only. then I added a new formula in subreport named f_sub. add added

Shared NumberVar balance;
balance := 5;

Now output would be 5 in subreport, but I want to display the same output(mean 5) in main report also. How ? I tried above post, but I am sure something I am missing. Please help what I am doing wrong.

1
Are you using the subreport formula in subreport to show as a field? Try removing it.Nisha
I have created two formulas one is in main report and another in sub report. And both are using shared variable.vikas
Try giving different names and if you are using the subreport formula to show as a field remove it. Just keep that formula in subreport but don't drag it into the subreport.Nisha
@Nisha I have different names to both formulas, and please clear this line "if you are using the subreport formula to show as a field remove it"vikas

1 Answers

0
votes

For eg: if you have a main report say 'MainReport' and sub report named 'SubReport' and you have @mainFormula and @subFormula in 'MainReport' and 'SubReport' respectively. Formula fields are just like other fields. You can add those fields to your report so that they show up when you run the reports. To solve your issue, if you are using @subFormula in 'SubReport' to show/display the value when running report, try removing it.