Pass numeric array to subreport as selection parameter

I have main report grouped by Store# within District.  I need to run a subreport in the District footer.  I wish to send all the store#'s in each district to the subreport for data selection. I have tried making an array of the store#'s, but I'm stuck as to how to get it to the subreport.  Is there a way to accomplish this?  All my Googling only turns up results for string arrays. Thanks.
DatakatCrystal Report DesignerAsked:
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:
You can't pass an array to a subreport for use in that way.

To be used in the selection filter, you can only use information passed through the links.

I can think of 2 ways to do this.

In the main report you will need a formula to convert your array of numbers to a string

Then in the subreport selection you can split the string and into an array of numeric strings and test.

Main report formula
WhilePrintingRecords;
Global NumberVar Array NumUnitsSelect;
Local StringVar strSelectUnits;
Local NumberVar Index;
For Index := 1 to UBound(NumUnitsSelect) do
    strSelectUnits := strSelectUnits & ";" & CStr(NumUnitsSelect[Index],0,'');

strSelectUnits

Open in new window


Subreport selection
CStr({Sheet2_.NumofUnit},0,'') IN Split({?StrSelectUnits},';')

Open in new window


The other way is a bit more complex.  The difference is you convert the string to an array of numbers and do the comparison that way
Local NumberVar Array NumUnitsSelect;
Local StringVar Array strUnitsSelect;
Local NumberVar Index;

strUnitsSelect := Split({?StrSelectUnits},';');
ReDim NumUnitsSelect[UBound(strUnitsSelect)];

For Index := 1 to UBound(strUnitsSelect) do
    NumUnitsSelect[Index] := Val(strUnitsSelect[Index]);

CStr({Sheet2_.NumofUnit},0,'') IN Split({?StrSelectUnits},';')

Open in new window


Here is a white paper that details the first idea
http://www.sdn.sap.com/irj/boc/go/portal/prtroot/docs/library/uuid/40e7130d-aa1e-2b10-ce9f-eee2a54ff4cd?QuickLink=index&overridelayout=true&29665339124157

mlmcc
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
DatakatCrystal Report DesignerAuthor Commented:
Would like to try the first solution, but I don't understand how strSelectUnits becomes a parameter in the subreport.  And I'm not sure the white paper you referenced is quite what I need, as it's for a chart?? Thanks.
0
mlmccCommented:
I realize the white aper is for a chart but they use the method to pass the information from the main report to the subreport.

Sorry forgot to explain how to connect them.

In the subreort create a parameter - strSelectUnits of type string

Add a link from the main report to the subreport using the main report formula link it to the parameter, strSelectUnits, in the subreport

Edit the subreport selection formula to include the line shown

mlmcc
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

James0628Commented:
mlmcc,

 The last line in your "more complex" suggestion seems off.  Shouldn't that be something like this?

{Sheet2_.NumofUnit} in NumUnitsSelect


 James
0
mlmccCommented:
Yes, you are correct.  That's what I get for copying the other code and failing to modify it all.

mlmcc
0
DatakatCrystal Report DesignerAuthor Commented:
I was not able to get this to work. I only got one item, not a list. At the moment the report is on hold anyway. Thank you for your suggestions.
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.