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
schraudogAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mlmccCommented:
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
0
James0628Commented:
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
0
schraudogAuthor Commented:
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
0
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

schraudogAuthor Commented:
mlcc,

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

mlmcc
0
James0628Commented:
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
0
schraudogAuthor Commented:
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?
0
James0628Commented:
> 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
0
schraudogAuthor Commented:
James,


Please refresh my memory on how you do number two?
0
James0628Commented:
Is the subreport using a stored procedure (with parameters)?  If it is, you'll need to use formulas in the main report to calculate the starting and ending dates for the month, so that they can be linked to the stored procedure parameters in the subreport.

 Assuming that the subreport is _not_ using a stored procedure, the simplest thing would probably be to pass the subreport the date field that you're using for the group, and have the subreport calculate the starting and ending dates from that.

 Create a date or datetime parameter in the subreport, if you don't already have one.  Just one parameter.  It will need to be the same type as the field that you're using for the month group in the main report, so that you can link the field to that parameter.  Link the field to the parameter in "Change Subreport Links".

 In the subreport, you would go to Report > Selection Formulas > Record and enter a formula like the following:

{subreport date field} >= Date (Year ({?dateparam}), Month ({?dateparam}), 1) and
{subreport date field} < DateSerial (Year ({?dateparam}), Month ({?dateparam}) + 1, 1)

 dateparam is obviously the parameter in the subreport that you linked to the date field in the main report.

 DateSerial is like the Date function, but if it gets an "invalid" value, it adjusts for it.  For example, if the date was in December, Month + 1 would be 13, which would give you an error with the Date function.  But DateSerial interprets month 13 as January of the next year.

 So, that looks for dates on or after the first day of the month in ?dateparam, and before the first day of the next month.

 James
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
schraudogAuthor Commented:
James,

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

Thanks.
0
James0628Commented:
You're welcome.  Glad I could help.

 James
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.