melegant99
asked on
Using Crystal Reports Array to Store Records?
Hi,
I have a report where there are two tables that hold info that are related to the same key field.
However, both of these tables hold multiple rows so I am having trouble figuring out how to deal with it in one sub-report (I can't do a sub-report in a sub-report, which would have been awesome).
Plus, table 1 gets displayed in details, table 2 info goes in the footer.
I was thinking to use an array. I would create the array in a formula, but I only want to add distinct values of the NAME on table 2. I then am thinking on looping through that array in the footer and displaying my values,
I am looking for some direction on the code for this, I have an idea but I am not sure how to only add distinct values into the array, how to declare the array so that the size is based on the # of distinct values, where to place the formula (I think I need to add something like whilereadingrecords right?)
Thanks,
I have a report where there are two tables that hold info that are related to the same key field.
However, both of these tables hold multiple rows so I am having trouble figuring out how to deal with it in one sub-report (I can't do a sub-report in a sub-report, which would have been awesome).
Plus, table 1 gets displayed in details, table 2 info goes in the footer.
I was thinking to use an array. I would create the array in a formula, but I only want to add distinct values of the NAME on table 2. I then am thinking on looping through that array in the footer and displaying my values,
I am looking for some direction on the code for this, I have an idea but I am not sure how to only add distinct values into the array, how to declare the array so that the size is based on the # of distinct values, where to place the formula (I think I need to add something like whilereadingrecords right?)
Thanks,
ASKER
Because the main report is using another table that is related to the order #.
There are in total 6 or 7 tables that all are related to the order #, but all have multiple rows. This is a rare time where I cannot break them out into seperate sub -reports.
There are in total 6 or 7 tables that all are related to the order #, but all have multiple rows. This is a rare time where I cannot break them out into seperate sub -reports.
Problem is you are going to get many "duplicates"
Main report
Table1 - Order1
Subreport
Table2 - Order1 - 5 rows
Table3 - Order1 - 4 rows
Result - 20 rows
Is there anything thin in table1 or 2 that can be used to limit the rows.
mlmcc
Main report
Table1 - Order1
Subreport
Table2 - Order1 - 5 rows
Table3 - Order1 - 4 rows
Result - 20 rows
Is there anything thin in table1 or 2 that can be used to limit the rows.
mlmcc
ASKER
No, but I was looking at another post of mine where I asked a question that was along the same lines, and based on something you said mlmcc you have given me an idea, and my question is how to do this:
1) Create a subreport that gathers the data I need. I would need to create 2 arrays, (1) one dimensional array that would have the value, and a 2 dimensional array that would hold the name and description. I could use whileprintingrecords to read these into the array right? Question is, how do I declare/size the array to match the number of records?
2) Pass these back to the main report? (how can I pass an array between reports?)
3) Pass the arrays to whatever sub report where I want to use that data and create a formula to show the array? (again, how to pass)
1) Create a subreport that gathers the data I need. I would need to create 2 arrays, (1) one dimensional array that would have the value, and a 2 dimensional array that would hold the name and description. I could use whileprintingrecords to read these into the array right? Question is, how do I declare/size the array to match the number of records?
2) Pass these back to the main report? (how can I pass an array between reports?)
3) Pass the arrays to whatever sub report where I want to use that data and create a formula to show the array? (again, how to pass)
ASKER
Wait, to further what I said before,
can I just declare a Shared Array Variable? If I do that in a sub-report, does it make it available everywhere?
Other than that, the other key thing that I am struggling with is how to create the array with the size of records returned, is there a function that would give me that number?
can I just declare a Shared Array Variable? If I do that in a sub-report, does it make it available everywhere?
Other than that, the other key thing that I am struggling with is how to create the array with the size of records returned, is there a function that would give me that number?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
All right, that works out great
except:
The subreport that is gathering data, well, it is not a report I want to show....it's sole purpose is to create that array so I can use it in conjuction with other sub-reports. If I supress the section where I place that subreport, well, it does not populate (WhilePrintingRecords). It seems that you cannot use WhileReadingRecords with a shared variable.
Is there a way around this?
except:
The subreport that is gathering data, well, it is not a report I want to show....it's sole purpose is to create that array so I can use it in conjuction with other sub-reports. If I supress the section where I place that subreport, well, it does not populate (WhilePrintingRecords). It seems that you cannot use WhileReadingRecords with a shared variable.
Is there a way around this?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Beautiful, you are the best mlmcc.
Does the main report use a different table?
Why can't you use the main report for table 1 then table2 goes in the subreport?
mlmcc