7. Sub Reports

This chapter shows how to incorporate "sub" reports into other reports when using the report designer.

Working with Sub Reports

A sub report is a fully functional report that can be added to other reports the same way other report elements are added.

There are two ways to add a sub report to a report:

  1. Using the 'File' menu and selecting 'New Subreport'.

    This will open a new window, identical in functionality and design to the main Report Designer window, where you will be able to design the new report, using the same rules and instructions outlined in the previous documents. After designing the sub report, it should be saved in a accessible location using a *.report extension.  This is how this report will be added to the "main" report later on.
     
  2. In the "Palette" toolwindow, select "SubReport" and drag it to the appropriate location on the design pane.

     

Sub Report Queries

If you are creating a sub report, chances are you will want to use a different query from your main report.  In order to do this, you will need to configure the datasets properly.  This procedure is very similar to the one explained in the quickstart guide.  Here is also a quick walkthrough:

  1. On the Structure toolwindow, select the dataset currently being used.
  2. Click the 'Configure' button at the bottom right side of the application.
  3. The 'Configure' window shows up.
  4. Click on 'Add'.
  5. A 'new' query is added to the list.  Rename it accordingly.  In my case, I renamed it to  'sub1'.
  6. Click on 'Query Designer' and select the schema/tables accordingly.
  7. Click the 'OK' button.
  8. You can now use this query in your sub report by using the name selected.
     
     

Sub Report Properties

The following properties can be editied when working with sub reports:

  • Name
    The name by which the sub report should be referenced.
  • Appearance
    • File Path
      This is the path where the *.report file is saved.
    • Query
      Refers to the name of the query, as defined in the datasets structure elements.  (See Sub Report Queries above.)
      This property is a text-field and its value should match exactly one of the queries defined in the dataset.
    • Parameters
      If the query used by the sub report contains parameters, this is where they should be specified.  These parameters are "imported" by the sub report.  Consider the query below:
      SELECT * FROM ORDERS WHERE "ORDERS"."CUSTOMERNUMBER" = ${CUSTOMERS_CUSTOMERNUMBER}
      The last element in the query,  CUSTOMERS_CUSTOMERNUMBER, is a parameter that will have to be passed into the sub report in other for it to function properly.

In order to manage parameters, click on the '...' button next to the 'Parameters' properties field. Two types of parameters are available:

      • Import parameters:
        Click the 'Add' button on the 'Formula' dialog under the Import parameters section.  The Outer name refers to the name this parameters is going to be exported as, where as Inner name refers to the name of the property in the "parent" report.  For instance, in the above example where you have a query that will use the CUSTOMER_CUSTOMERNUMBER parameter in the query you need to IMPORT this into the subquery. 
      • Export parameters:
        • In the "Data" menu, click on "Edit Sub-report Parameters...".
    • Position
      Indicates where the sub report should be placed within its parent report.  This is automatically updated by dragging the sub report element in the design pane.
    • Minimum Size
      The smallest size for this sub report element.

Running Sub Reports

After designing your sub report, you can view the data by simply previewing either the sub report directly or the parent report. 

Lastly, there are no limitations to how many sub reports can be attached to a report, and obviously, a sub report can also contain other sub reports.

Examples