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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Very Urgent. Need any array to store IDs and pass them to a subreport

Status
Not open for further replies.

yehong

Programmer
Sep 22, 2003
291
US
I need to write a function that stores IDs and then passes them to the subreport for record selection in the subreport.
I am using CR8.5. This is very urgent as I have to deliver this report in 2 hours. Initially we were using a string to hold IDs, but it is erroring out when the length goes over 254 characters.
Thanks.
 
A quicker solution would be to use more than one string and code the record selection formula accordingly.

Anyway, an array might work as follows:

whileprintingrecords;
stringvar array MyArray; //declares it
redim preserve MyArray[ubound(MyArray)+1]; //resizes
MyArray[ubound(MyArray)]:= "Hi"; //Adds a value

Since you've given no indication as to where this array is being populated, nor the source of the arrays data, this should serve as a reasonable example of how to create, resize and populate arrays.

-k

 
I need to populate the array in the details sections, then pass that array to subreports record selection.

Here is sample layout for understanding the array logic:

Store Number :1 (Group Header, group is on Store Number)
Id Amount
1001 $300
1002 $200
1003 $400
(need an array here to store above three ids)

SubReport (in the Group Footer of Store Number) :
(Purpose: need to show order history for above three ids only)

Id Date Amount
1001 04/01/04 $100
1001 04/29/05 $300
1002 04/29/05 $200
1003 04/29/05 $400.
 
I don't think that this will work well as shared variables work at the whileprintingrecords level.

Anyway, the theory is that in the group header place:

whileprintingrecords;
stringvar array MyArray; //declares it
redim MyArray; //resizes and sets it to blank

In the details use:

whileprintingrecords;
stringvar array MyArray; //declares it
redim preserve MyArray[ubound(MyArray)+1]; //resizes
MyArray[ubound(MyArray)]:= {table.field}; // Add a Value

If it's a numeric field, wrap it in totext()

Then use the field to link to the subreport IDs, not by
using it in the record selection formula.

-k
 
I am getting errors when trying to use this formula:
whileprintingrecords;
stringvar array MyArray; //declares it
redim MyArray; //resizes and sets it to blank

First error points to 'redim MyArray;' line for '['. When I insert [], I get a different error, 'Result of a formula can not be an array'. Any idea what am I doing wrong?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top