Link to home
Start Free TrialLog in
Avatar of Nicole McDaniels
Nicole McDaniels

asked on

shared number array to be used in subreport

I have searched multiple websites and have had no luck. I have never created a number array so any help with the formulas would be great. I want to create an array of Record ID's and pass those to a subreport to further process values from those record ID's. Could someone please tell me what the formulas would be? Everything I try I get an error because it's number and not string.

Main Report IDs
1234
2345
3445
6678
7789
9789

Send those 6 records to the subreport to be used (there is no limit on the number of IDs that will be sent; it varies)
Avatar of Mike McCracken
Mike McCracken

I assume you are trying to select records based on the array.
If you need something else let us know.

This method will only work for a subreport placed in the report footer or a group footer

In the main report header add a formula
WhilePrintingRecords;
Global StringVar Array ID_List;
Global NumberVar ID_Count;
''

Open in new window


In the detail section (or the section where you want to gather the record ids)
WhilePrintingRecords;
Global StringVar Array ID_List;
Global NumberVar ID_Count;
ID_Count := ID_Count + 1;
ReDim Preserve ID_List[ID_Count];
 ID_List[ID_Count]:= CStr({RecordID Field},0,'')
''

Open in new window


Add a formula ( to be used as the link)
WhilePrintingRecords;
Global StringVar Array ID_List;
Join(ID_List,chr(13))

Open in new window


Use the formula as the link on the subreport record ID

Edit the subreport
Edit the Selection formula
CStr({subreport Record ID Field},0,'') IN {?pm_RecordID}

Open in new window


mlmcc
Avatar of Nicole McDaniels

ASKER

Should there be a semi colon for the detail formula after CStr({RecordID Field},0,'')    ? There was an error. I added it there and when I display my main report, there are no values. Shouldn't it display all the ids?

Then, when I try to link my formula to the subreport, I assume it's a string as it's not even displaying the Record ID field in the subreport to allow me to link
Yes.

If you want to see the display change the '' to Join(ID_List,',  ')

mlmcc
I am able to see all the ID's passed to the subreport but now I'm not getting any data in my subreport. Is it because it sees the numbers as strings and not as ID's?

Shouldn't this be number?

WhilePrintingRecords;
Global StringVar Array ID_List;
Join(ID_List,chr(13))

I am using this in the subreport:
CStr({PR.ID},0,'') IN [{?Pm-@SubLink}]
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>>Shouldn't this be number?

You can't pass arrays as parameters so you have to convert it to a string of values.
You could convert it back to an array of numbers but the code would take longer to run than converting the values from the database.

mlmcc
Thank you SO Much!!!
This is the only number array anywhere. Thanks so much!