Skip to Content
Former Member
Apr 01, 2011 at 03:58 PM

How to pass an array to a sub report and use it as selection criteria


Hey All,

I am new to crystal reports so if I miss something obvious i apologize. I have a main report that has seven or so sub reports in it. Each of the seven sub reports and the main report come from separate data sources. I want to make a selection on a group in the main report and pass all of the items in that group to each of the sub reports so that I can automate and burst this report out on category from the scheduler. I have placed a formula in the detail section of my report that populates the array. My problem is how do I pass this to the sub report and use it so that it is used in the record or group selection? I have been trying to figure this out for 4 days on several different tech sites, ittoolbox, linkedin,tek-tips, ken hamady, crystalreportexperts,etc. I even went into a paid site but they have failed to be able to help me figure this out. 😔

This is the formula placed in the detail section of my main report.

one of the datatbases has the data stored as a number and the rest have it stored as a string, I know that stinks.

//declare a string and a numeric array

shared stringVar array strAccountIDs;

shared numberVar array numAccountIds;

//incrementing record count by one for inserting into an array

shared numberVar MyCounter;

if MyCounter < 1 Then MyCounter:=1 ELSE MyCounter:=MyCounter + 1;

//resize the array for each record (limit is 1000)

redim preserve strAccountIDs[MyCounter];

redim preserve numAccountIds[MyCounter];

//load the shared arrays

strAccountIDs[MyCounter] := totext({Clients_by_Segment.ClientIdNumber});

numAccountIds[MyCounter] := tonumber({Clients_by_Segment.ClientIdNumber});

//this is not needed, just distplays something from the formula, you can

//replace with empty quotes


Thanks an I would appreciate any help or direction.