Search code examples
crystal-reports

Crystal Reports: Create Array or get values from a column


Say I'm working on a report, on a column called someTable.someColumn. What I need is to have all of the values in the ReportHeader. I know I cound create a subreport, pass them this column and iterate it in the details, but I would like to know if it's possible to do it without a subreport.

If I use the following, I get the right result, which in my case is 9:

COUNT(someTable.someColumn)

I also tried the following, but it doesn't work - it only takes one of the 9 values randomly.

Local NumberVar i := 0;
Local StringVar Array items := {someTable.someColumn};
Local StringVar output := "";
while (i < count(items)) do (
  i := i+1;
  output := output + items[i];
);

output;

Is it possible to iterate over a column in order to get the values?


Solution

  • You can't do this in the report header. You have to use the detail section to read each value.

    The only solution which springs to mind is using a subreport. Although you wouldn't pass them this column and iterate it in the details. Because it would only pass the first value from the column. You would pass it the report parameters which it could use to obtain the column values from the database the same way your main report does.