Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to store values in an array and pass to a subreport

Status
Not open for further replies.

yehong

Programmer
Sep 22, 2003
291
US
CR8.5.
I have a report that prints phone numbers for each person. I have a subreport in that main report in which I want to pass all numbers from the main report.
I am thinking that array might do it.
Is there an easy way to do it?
 
If you want to use an array, here's how.

This formula would go into the Details section (or wherever you're getting the phone numbers):

//@AddPhoneNumbersToArray
WhilePrintingRecords;
Shared StringVar Array PhoneNumbers;
If UBound(PhoneNumbers) = 1 And Minimum(PhoneNumbers) = "" then
ReDim PhoneNumbers[1]
else
ReDim Preserve PhoneNumbers[UBound(PhoneNumbers) + 1];

PhoneNumbers[UBound(PhoneNumbers)] := {Table.PhoneNumber};
"";

In the subreport, you would create another formula to access the array. This example would just display the array as a comma separated list in the subreport:

//@DisplayPhoneNumbers
WhilePrintingRecords;
Shared StringVar Array PhoneNumbers;
Join(PhoneNumbers, ", ");

Since you didn't mention what you were wanting to do with an array of phone numbers in a subreport, that's the best I can do at this point.

-dave
 
Thanks Dave. The reason I need to pass all Numbers to the subreport is that the subreport further filters down those numbers and shows only those records that meet the criteria. The main report lists everybody. I have created both formulas and the subreport formula is diplaying only one record (phone number). Also I am unable to use the subreport formula (//@DisplayPhoneNumbers ) in my record selection.
 
To use the PhoneNumbers array in the record selection of the subreport, you would have to declare the variable first:

WhilePrintingRecords;
Shared StringVar Array PhoneNumbers;
{Table.PhoneNumber} in PhoneNumbers

If the subreport formula is only giving you a single record, then you'll need to describe the layout of your report (e.g. where you're using the @AddPhoneNumbersToArray formula, and what section the subreport is in.

-dave
 
I have the //@AddPhoneNumbersToArray in the Details section of the main report, the subreport is in the Report Footer section of the main report and //@DisplayPhoneNumbers formula is in the Report Header section of the subreport.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top