Ingrid Bowrin
asked on
Sharing values from subreport to main report in Crystal Reports
I am trying to share a variable from a subreport with a main report in Crystal 2011. In the subreport we are using the following code;
WHILEPRINTINGRECORDS;
SHARED NUMBERVAR SAVAL := Sum ({PLS_POLICYSUBAGENT.PLS_A MOUNTT}, {PLS_POLICYSUBAGENT.PLS_VE RNO})
The main report uses the following code;
WHILEPRINTINGRECORDS;
SHARED NUMBERVAR SAVAL; SAVAL;
When we put "@SAVAL" in the main report to use in another formula the results are not being displayed. When we try to display "@SAVAL" it is not lining up with the data on the Details line. (See attached screenshot).
Can someone help me resolve this please?
Doc112.docx
WHILEPRINTINGRECORDS;
SHARED NUMBERVAR SAVAL := Sum ({PLS_POLICYSUBAGENT.PLS_A
The main report uses the following code;
WHILEPRINTINGRECORDS;
SHARED NUMBERVAR SAVAL; SAVAL;
When we put "@SAVAL" in the main report to use in another formula the results are not being displayed. When we try to display "@SAVAL" it is not lining up with the data on the Details line. (See attached screenshot).
Can someone help me resolve this please?
Doc112.docx
ASKER
1. Yes the value from the sub report is being displayed in the main report. But we also need to use it in a formula to calculate another total in the main report.
2. The sub report is in a section above the field looking for the shared value.
2. The sub report is in a section above the field looking for the shared value.
1. Displaying it in main report is fine, is it being used in sub report to set the value for the same? Can you run the sub report whether the value is being set?
You need to pull the formula field into the report design area in sub report to set the value, then only the value will be available in main report.
You need to pull the formula field into the report design area in sub report to set the value, then only the value will be available in main report.
You have one in the details section and the other in the group footer.
Try this
Right click the detail section in the left margin
Click SECTION EXPERT
Make sure the detail section is selected
Click to check UNDERLAY FOLLOWING SECTION
Close SECTION EXPERT
mlmcc
Try this
Right click the detail section in the left margin
Click SECTION EXPERT
Make sure the detail section is selected
Click to check UNDERLAY FOLLOWING SECTION
Close SECTION EXPERT
mlmcc
ASKER
I got the field to line up in the report, (we split the detail section into detail a & detail b and put the sub report in a and the shared varible in b) however, I want to do a sum on it in the group footer. However, when I right click on it to summarize it I'm not getting the option to summarise it.
You cannot summarize a field containing WhilePrintingRecords;
An option would be to store the value from shared variable into another variable and use that variable for summarization.
An option would be to store the value from shared variable into another variable and use that variable for summarization.
ASKER
Thanks for the feedback. Can I get an example please?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
THe problem is summaries are done in one of the early passes through the report but the shared variables are not evaluated until the last or next to last pass through the report thus they aren't available when the summary functions are evaluated.
The easy way t do what you want is a 3 formula summary
Formula 1 declares a global variable in the group header and sets it to 0
Formula 2 in your case in the detail section B you would have a formula to add the current value to the total
Formula 3 goes in the group footer to display the total
I didn't look at the sample report but that is what it should be doing.
mlmcc
The easy way t do what you want is a 3 formula summary
Formula 1 declares a global variable in the group header and sets it to 0
Formula 2 in your case in the detail section B you would have a formula to add the current value to the total
Formula 3 goes in the group footer to display the total
I didn't look at the sample report but that is what it should be doing.
mlmcc
ASKER
Thanks mlmcc for the answer. We have done all that but the summarized value is not resetting. However, we had to do a reset function for the formula in Detail b. Could this reset function be preventing the second reset function to work?
What is the reset function in detail B?
mlmcc
mlmcc
ASKER
The reset formula is;
shared numbervar saval :=0;
"saval" is the shared variable from the subreport. This one works just fine.
shared numbervar saval :=0;
"saval" is the shared variable from the subreport. This one works just fine.
Can you upload the report you have with the second set of formulas?
mlmcc
mlmcc
Couple of things to check:
1. Is the field which is created in sub report is used in the report to set the value for the same? Unless it's used in the report, the value will not be set.
2. Is your sub report in a section above the section in which your main report field is looking for shared value?