Crystal Reports: passing calculated data through parameter to subreport

77 views Asked by At

This is my first time working with subreports, but I have about 6 months of Crystal experience.

I am constructing a daily report for sales managers, where they can get a summary of each of their salespeople's activity (open orders, quotes, etc.). This report already exists as an individual sales report, where they get more details on their activity, so I'm using a summarized copy of that report as a subreport for the new Manager version.

My issue is

  1. generating the list of salespeople under the sales manager, eg: "if parameter = managercode then select salesperson where salesperson_managercode = managercode" Getting stuck on this logic, can't seem to crack it.
  2. passing the above list through the subreport, one at a time. Essentially a loop. From there I want to total everything to provide a Team Total at the bottom.

Any help is appreciated!!

1

There are 1 answers

0
R. McMillan On

You shouldn't need to worry about the looping structure. The report will take care of that for you. If you have a dataset where each row represents 1 manager, then placing your subreport within a section that repeats for each record in the dataset will allow the subreport to effectively loop through each record in the dataset.

The employees who are supervised by each manager can then be selected by using the "link" between the main report and the subreport. A "link" is defined in your subreport's setup by declaring a field from the database in the main report and a field within the database of the subreport. The field in the subreport should be a Foreign Key that corresponds to the field in the main report. Following the example of managers and employees, your main report would have a dataset the represents Managers. This dataset should have a primary key such as Manager_ID. Then your subreport that represents the Employees would have a dataset that contains columns such as Employee_ID as a Primary Key that is unique for each employee, as well as a foreign key such as Manager_ID that indicates which manager is responsible for the given employee. When linking the subreport and main report you will want to use Manager_ID as the "link" between them.

I hope this helps, or at least helps you get started!