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
Crystal Reports

Avatar of undefined
Last Comment
James0628

8/22/2022 - Mon
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
James0628

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
ASKER
schraudog

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
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
ASKER
schraudog

mlcc,

I tried that and it did not help. I want to group see the total quantity for a month group range.
Mike McCracken

Did you link the subreport to the main report?

mlmcc
James0628

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
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
schraudog

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?
James0628

> 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
ASKER
schraudog

James,


Please refresh my memory on how you do number two?
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
ASKER CERTIFIED SOLUTION
James0628

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
schraudog

James,

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

Thanks.
James0628

You're welcome.  Glad I could help.

 James