Passing a running total value into it's associated group in the main report

John-S Pretorius
John-S Pretorius used Ask the Experts™
on
I'm grouping by UserID and trying to pass running totals from a subreport into each associated UserID, not certain if this is possible in Crystal Reports 2016
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
You can use a shared variable to pass a value from a subreport back to the main report (or to another subreport).  AFAIK, that is the only way.  It may be simple, or not, depending on the structure of your report, and the value(s) that you're trying to pass.

 Are you running the subreport for each UserID?  If so, and you want to pass a total for each UserID back to the main report, you can just put that total in a shared variable.  The only "trick" to it is that the subreport needs to be in a main report section that's before the section where you want to use that variable (because any formulas in a main report section with a subreport will be evaluated before the subreport is run).

 Create a formula like this (call it whatever you like) and put it in the main report header, to declare the variable:

Shared NumberVar user_total;
""

 The "" is so that the formula doesn't produce any visible output on the report.  You could also suppress that field, or the entire section (in my experience, the formula is still evaluated).

 Use a formula like this in the subreport to save the total:

Shared NumberVar user_total;
user_total := {your running total or whatever};
""

 And then you can use that user_total shared variable in a formula in the main report (in a section after the one that the subreport is in) to get that total.

 James
John-S PretoriusSystems Engineer

Author

Commented:
Hi James, and thank you for the feedback. I actually tried implementing a subreport (placed in the ReportHeader) to process the value for each userID, I also tried grouping the subreport in the exact format as the actual main report but still having issues getting the GroupID values passed thru to each group in the main report.

This is a critical item for me so any guidance with this will be appreciated.
I think the basic problem is that you're looking for separate totals for each UserID, but you're not running the subreport separately for each UserID (if the subreport is in the report header).

 Normally you would group the main report by UserID and put the subreport in the group header, linked on the UserID, to get the total(s) for each UserID.

 James
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

John-S PretoriusSystems Engineer

Author

Commented:
Thank you James, I followed your guidance and made some changes as recommended. The values are being passed into the group header as expected.
John-S PretoriusSystems Engineer

Author

Commented:
Thank you.
You're welcome.  Glad I could help.

 James

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial