Link to home
Create AccountLog in
Avatar of schraudog
schraudogFlag for United States of America

asked on

Trying to Share values from subreport to main report

I have a main report that is sorted by Date range (monthly) and a sub report that is also sorted the same way. I have quantities by month on the sub report that I want to link/share with the main report and am unable to. I created a shared numbervar that brings over only the last quantity for the months listed on the sub report.

I would like to see the quantities for each month from the subreport viewed on the main report.

Attached is a snap shot of my subreport data in the box and the main report. Any suggestions would be greatly appreciated.
Capture.JPG
Avatar of Mike McCracken
Mike McCracken

WHat value do you want the shared variable to have?

I suspect what you need is a formula in the subreport in the detail section

WhilePrintingRecords;
Shared NumberVar myTotal;
myTotal := myTotal + {subreportvaluefield};


mlmcc
The box is your subreport?  Is it supposed to produce the same list of numbers over and over?  That seems redundant.

 How do the numbers in the subreport relate to the main report?  Which figures do you want to see where?

 Your first highlighted field will _always_ be 0 if it's before the first subreport.  If you need to see a figure from the subreport before you display the actual subreport, you'll need to add an extra copy of that subreport that sets a variable and doesn't display any output, and put that subreport in a section before the section that the first highlighted field is in.

 James
Avatar of schraudog

ASKER

James,

I tried that and now I get the quantities in the first group but they are still duplicating.

Here is a screen shot.
Capture.JPG
mlcc,

I tried that and it did not help. I want to group see the total quantity for a month group range.
Did you link the subreport to the main report?

mlmcc
The question remains, exactly what are you trying to do with the numbers in the subreport?

 I suspect that the numbers in the subreport are month totals, and you want to show each month total from the subreport with the corresponding month in the main report.  If so, that can get somewhat complicated.

 OTOH, if you don't actually need to see that output from the subreport on the main report and the reason for the subreport is just to get those totals, then maybe (as mlmcc may have been suggesting) you need to pass the month and year to the subreport so that it only includes the correct month each time it's run, and then the figure that you get in the main report will be for the correct month.

 James
mlmcc,

I linked the subreport to the main report by date range. I have a Parameter on the main report linked to the subreport that has a date parameter as well.

James,

I am trying to get the monthly output from the subreport on the main report. Sounds like I am trying do to something out of the normal functionality of Crystal?
> Sounds like I am trying do to something out of the normal
 > functionality of Crystal?

 Not necessarily, but how, or if, you can do what you want in CR will be determined by exactly what you're trying to do.

 For example, if you have the main report grouped by month and run the subreport in the group header (ie. for each month), but you just pass the subreport the starting and ending dates for the main report (eg. 01/01/2013 to 08/31/2013), then the subreport is going to include all of those months every time it's run.  If you set a normal variable in the subreport, it will only have one value at the end of the subreport (eg. a grand total from the subreport, or the total for the last month included in the subreport).

 OTOH, if you run the subreport in the month group header and, for example, pass the starting date for that group (ie. the beginning of the month) to the subreport, instead of passing it the starting and ending dates for the entire report, then the subreport will include only that month, and the variable will have the total for that month.

 Does that help?

 James
James,


Please refresh my memory on how you do number two?
ASKER CERTIFIED SOLUTION
Avatar of James0628
James0628

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
James,

That did it. Now I have to get that data on a chart.

Thanks.
You're welcome.  Glad I could help.

 James