• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 350
  • Last Modified:

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.
0
Datakat
Asked:
Datakat
  • 3
  • 2
2 Solutions
 
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
 
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
[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

 
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

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now