When designing a DataWindow object for a report, you can choose to nest other reports (which are also DataWindow objects) within it. The basic steps for using nested reports in an application are the same ones you follow for the other report types. There are, however, some additional topics concerning nested reports that you should know about.
To learn about designing nested reports, see the section called “Using Nested Reports” in Users Guide.
Printing multiple updatable DataWindows on a page
An advantage of composite reports is that you can print multiple reports on a page. A limitation of composite reports is that they are not updatable, so you cannot directly print several updatable DataWindows on one page. However, there is an indirect way to do that, as follows.
You can use the GetChild method on named nested reports in a composite report to get a reference to a nested report. After getting the reference to the nested report, you can address the nested report during execution like other DataWindows.
Using this technique, you can call the ShareData method to share data between multiple updatable DataWindow controls and the nested reports in your composite report. This allows you to print multiple updatable DataWindows on a page through the composite report.
To print multiple DataWindows on a page using a composite DataWindow:
-
Build a window or form that contains DataWindow controls with the updatable DataWindow objects.
-
Define a composite report that has reports corresponding to each of the DataWindows in the window or form that you want to print. Be sure to name each of the nested reports in the composite report.
Naming the nested report
To use GetChild on a nested report, the nested report must have a name. To name a nested report in the DataWindow painter, double-click it in the workspace and enter a name in the Name box on the General property page.
-
Add the composite report to the window or form (it can be hidden).
-
In your application, do the following:
-
Retrieve data into the updatable DataWindow controls.
-
Use GetChild to get a reference to the nested reports in the composite report.
-
Use ShareData to share data between the updatable DataWindow objects and the nested reports.
-
When appropriate, print the composite report.
-
The report contains the information from the updatable DataWindow objects.
Re-retrieving data
Each time you retrieve data into the composite report, all references (handles) to nested reports become invalid, and data sharing with the nested reports is terminated. Therefore, be sure to call GetChild and ShareData each time after retrieving data.
Creating and destroying nested reports during execution
You can create and destroy nested reports in a DataWindow object dynamically during execution using the same technique you use to create and destroy other controls in a DataWindow object.
Creating nested reports
To create a nested report, use the CREATE keyword with the Modify method. Supply the appropriate values for the nested report's properties.
Viewing syntax for creating a nested report
The easiest way to see the syntax for creating a nested report dynamically is to export the syntax of an existing DataWindow object that contains a nested report. The export file contains the syntax you need.
For more information about exporting syntax in the Library painter, see Users Guide.
When creating a nested report, you need to re-retrieve data to see the report. In a composite report, you can either retrieve data for the whole report or use GetChild to get a reference to the new nested report and retrieve its data directly. For nested reports in other reports, you need to retrieve data for the base report.
Destroying nested reports
To destroy a nested report, use the DESTROY keyword with the Modify method. The nested report disappears immediately.
For more about creating and destroying controls in a DataWindow object or report, see Dynamically Changing DataWindow Objects.
For a list of properties of nested reports, see the section called “Properties for Report controls in DataWindow objects” in DataWindow Reference.