Accessing Parent Report’s Data from Sub-Report

Accessing Parent Report’s Data from Sub-Report

Applies to: Kyvos Reporting


Sub-reports in Kyvos Reporting can access data from their parent report by referencing the parent report’s fields as parameters. These parameters are automatically created when you embed a sub-report. However, when using a referenced sub-report, you must manually define the parameters in the sub-report.

Parameter Mapping

Field values from the parent report are passed to the sub-report as parameters. The parameter names are the same as the field names (or aliases, if used) from the parent report.

Example:

  • Parent report SQL:

    SELECT ORDERS.ORDER_NO, ORDERS.ORDER_DT FROM ORDERS
  • Sub-report parameters:

    ORDER_NO, ORDER_DT
  • Sub-report SQL:

    SELECT ORDRDETL.ORDER_NO, ORDRDETL.PROD_NO, ORDRDETL.PRICE, ORDRDETL.QTY FROM ORDRDETL WHERE ORDRDETL.ORDER_NO = <%ORDER_NO%>
image-20250725-080247.png

Guidelines

  • When using embedded sub-reports, Kyvos Reporting automatically creates the required parameters.

  • When using referenced sub-reports, you must manually create these parameters using the same names (or aliases) as used in the parent report.

  • You can use these parameters in the sub-report layout or directly within SQL queries as filters.

Handling Duplicate Field Names

If the parent report includes multiple fields with the same name from different tables (e.g., product.prod_no and invoice.prod_no), use aliases in the parent report SQL to avoid conflict.

Example:

SELECT product.prod_no AS PprodNo, invoice.prod_no AS InvProdNo FROM product, invoice

In the sub-report, use the parameters PprodNo and InvProdNo accordingly.

Important
When using a numeric parameter as a filter in sub-report SQL, ensure that a default value is set for that parameter. Omitting a default value may result in a SQL error.

Using Stored Procedures in Sub-Reports

Stored procedures can be used in sub-reports in the same way as in the parent report. Configure the data source to use a stored procedure, pass required parameters from the parent report, and define the output structure accordingly.

Copyright Kyvos, Inc. 2026. All rights reserved.