ActiveReports 13
Master Detail Reports
ActiveReports 13 > ActiveReports User Guide > Samples and Walkthroughs > Walkthroughs > Page Report/RDL Report Walkthroughs > Data > Master Detail Reports

You can create a master detail report using the Table control and grouping. The following walkthrough takes you through the step by step procedure of creating a Master Detail report.

The walkthrough is split into the following activities:

Note:

When you complete this walkthrough you get a layout that looks similar to the following at design time and at run time.

Design-Time Layout

Run-Time Layout

To add an ActiveReport to the Visual Studio project

  1. Create a new Visual Studio project.
  2. From the Project menu, select Add New Item.
  3. In the Add New Item dialog that appears, select ActiveReports 13 Page Report and in the Name field, rename the file as rptMasterDetail.
  4. Click the Add button to open a new fixed page report in the designer.
  5. For a $$RDL report$$, from the Report menu, select Convert to RDL Report.

See Adding an ActiveReport to a Project for information on adding different report layouts.

To connect the report to a data source

  1. In the Report Explorer, right-click the Data Sources node and select the Add Data Source option or select Data Source from the Add button.
  2. In the Report Data Source Dialog that appears, select the General page and in the Name field, enter a name like ReportData.
  3. On this page, create a connection to the Reels database. See Connect to a Data Source for information on connecting to a data source.

To add a dataset

  1. In the Report Explorer, right-click the data source node and select the Add Data Set option or select Data Set from the Add button.
  2. In the DataSet Dialog that appears, select the General page and enter the name of the dataset as CustomerOrders. This name appears as a child node to the data source icon in the Report Explorer.
  3. On the Query page of this dialog, in the Query field enter the following SQL query.
    SQL Query
    Copy Code
    SELECT CustomerID, Title, LastName, Quantity, Price, [Quantity]*[Price] AS
    Total FROM CustomerOrders WHERE CustomerID < 1010
    
  4. Click the Validate DataSet icon at the top right hand corner above the Query box to validate the query.

  5. Click OK to close the dialog. Your data set and queried fields appear as nodes in the Report Explorer.

To create a layout for the report

To add a table with grouping to the report

  1. From the toolbox, drag a Table data region onto the report design surface and go to the Properties Window to set its Location property to 0in, 1in.
  2. Click inside the table to display the column and row handles along the top and left sides of the table.
  3. To visually group the data within the report, right-click the row handle to the left of the detail row and select Insert Group.
  4. In the Table - Groups dialog that appears, under Expression select =Fields!CustomerID.Value.
    This groups the details from each customer.
  5. Change the Name to Customer.
    Note: You cannot change the name of a table group until you have set the expression.
  6. Click OK to close the dialog. The group header and footer rows are added to the table.

To add a fourth column to the table

  1. Select the second column and in the Properties Window, change its Width property to 0.92in.
  2. Select the third column and in the Properties Window, change its Width property to 1.04in.
  3. Select the first column and in the Properties Window, change its Width property to 3.5in.
    Tip: Making some columns narrower before making other columns wider prevents your report width from changing.
  4. Right-click the column handle above the third column and select Insert Column to the Right. The inserted fourth column has the same width as the third column, which is 1.04in.

To add data to the table

  1. Place your mouse over the Textbox located in the first column of the group header row of the table to display the field selection adorner
  2. Click the adorner to display the list of available fields from the DataSet and select LastName. This automatically places an expression in the group header row and simultaneously places a static label in the table header row.
  3. In the Properties window, set the FontSize property of this textbox to 12pt.
  4. In the table header row, delete the static label Last Name.
  5. To display static labels at the beginning of each new group, right-click the row handle to the left of the group header row and select Insert Row Below.
  6. In the first column of the detail row, use the field selector adorner to select the Title field.
  7. In the textbox immediately above it, type Title.
  8. In the table header row, delete the static label Title.
  9. In the second column of the detail row, use the field selector adorner to select the Quantity field. This automatically places an expression in the detail row and simultaneously places a static label in the header row of the same column.
  10. In the Properties window, set the TextAlign property of the Quantity field to Left.
  11. Cut the static label and paste it into the inserted row immediately above the detail row.
  12. In the third column of the detail row, use the field selector adorner to select the Price field.
  13. In the Properties window, set the following properties.
    Property Name Property Value
    TextAlign Left
    Format C (uses currency formatting)
  14. Cut the static label from the group header and paste it into the inserted row immediately above the detail row.
  15. Select the Total field for the fourth column of the detail row of the table.
  16. In the Properties window, set the following properties.
    Property Name Property Value
    TextAlign Left
    Format C (uses currency formatting)
  17. Cut the static label from the group header and paste it into the inserted row immediately above the detail row.

To refine the look of the report

  1. Right-click any row handle to the left of the table and select Table Header to remove the table header row since it is not being used.
  2. Select the Header row containing the labels by clicking the table handle to the left of the row.
  3. In the Properties window, set the following properties.
    Property Name Property Value
    RepeatOnNewPage True
    FontWeight Bold
  4. From the Report Explorer, drag the Total field into the group footer row in the fourth column to add subtotaling to the group. Notice that the expression automatically uses the Sum function.
  5. Go to the Properties window to set the following properties.
    Property Name Property Value
    Format C (uses currency formatting)
    FontWeight Bold
  6. From the Report Explorer, drag the Total field into the table footer row in the fourth column. This adds grand totaling to the table.
  7. Go to the Properties window to set the following properties.
    Property Name Property Value
    Format C (uses currency formatting)
    FontWeight Bold
  8. Delete the static label Total from the top row.
  9. In the Report Explorer select the Table data region and set its FixedSize property to 6.5in, 7in.
    Note: This step is valid only for Page report. For RDL report, follow steps 10-12.
  10. For RDL reports, click the gray area below the design surface to give report the focus and from the Report menu, select Page Header.
  11. From the toolbox, drag the TextBox control onto the PageHeader section to span the entire width of the report.
  12. Go to the Properties Window to set the following properties.
    Property Name Property Value
    TextAlign Center
    FontSize 14pt
    Value Customer Orders

To view the report

OR

See Also