Search code examples
crystal-reportssubreports

can variable from subreport be used to group information in the main report (crystal 10)


I have set up a main report that has 2 subreports coming into it.
The main report consists of one table : ROOM & two parameters: STARTDATE and ENDDATE. The date range is only in the main report so it can be displayed in the title area. More importantly, it links to the 2 subreports.

Right now, the main report is grouped by Facility and then by Room name. Everything is working great until I try to run it for more than one day. What I want is for the main report to also be grouped by the date, but I don’t know if that is possible as the ROOM table does not contain a date field to link the parameters to so that I could use it in the groupings.

Is it possible to create a Date variable within the subreport that could then be passed back to the main report to be used for grouping? I apologize if this is a dumb question, but I do not work with variables often and shared variables even less than any other.


Solution

  • Short answer: No. You can never group a main report with variables from a subreport. Crystal determines a report's groups early in the evaluation process, before it ever looks at any subreports.

    In general, you might want to ask yourself how to avoid the use of subreports in the first place. In my mind the use of a subreport is a last ditch effort when there is simply no other way to accomplish what you want in a single report. In your case, if your main report is only made up of a single table (ROOM), then you would simply need to move the tables from your subreport to the main report, then join them to ROOM. Doing it this way would leave you free to easily group on whatever fields you wanted.