Share via


Visual Basic Concepts

Extending the Data Report

Once you have a simple data report, it's easy to extend it and make a more complex presentation. In the procedure below, the data environment is first extended with the Order Details and Products tables. The extended report includes the names of products ordered on a specific date, and resembles the figure below.

Extended Data Report With Order Details

Note   This topic is part of a series that walks you through creating a sample data report. It begins with the topic, Creating a Simple Data Report.

To extend the data environment

  1. On the Data Environment designer, right-click the Orders Command object. Then click Add Child Command.

  2. On the Command1 Properties dialog box, set the following properties:

Property Setting
Command Name OrderDetails
Connection Northwind
DataBase Object Table
Object Name Order Details
3. Click the **Relation** tab. The **Relate to a Parent Command Object** check box should be checked. The **Parent** box should contain **Orders**; both the **Parent Fields** and **Child Fields/Parameters** boxes should contain **OrderID**. Click the **Add** button and then click **OK** to close the dialog box. 4. Right-click the **OrderDetails** Command object, and click **Add Child Command**. Set the properties of the connection as shown below:
Property Setting
Command Name Products
Connection Northwind
DataBase Object Table
Object Name Products
5. Click the **Relation** tab. The **Relate to a Parent Command Object** check box should be checked. The **Parent** box should contain **OrderDetails**; both the **Parent Fields** and **Child Fields/Parameters** boxes should contain **ProductID**. Click the **Add** button and then click **OK** to close the dialog box.

Extending the Data Report

Once the data environment has been extended with new tables, you can extend the data report as well by dragging fields from the Data Environment designer to the Data Report designer.

To Extend the data report

  1. Right-click the Data Report designer, and clear Show Page Header/Footer box.

    Clearing this option deletes the page header and footer, which are not being used at this point.

  2. Right-click the Data Report designer, and click Insert Group Header/Footer. The Insert New Group Header/Footer dialog box will be displayed.

    The dialog box allows you to determine if the new header and footer will "bracket" other header/footer pairs. This becomes important as you add more header and footer pairs because the outermost pair of header/footers subordinates all other pairs. This is discussed in greater detail in "Parts of the Data Report."

  3. Click OK to select the default placement of the new header and footer pair and close the dialog box.

  4. Select the new group header, and on the Properties window, change its name from Section1 to Orders_Header. Change the corresponding footer name from Section4 to Orders_Footer.

  5. Repeat steps 2 to 3. Name the new group header OrderDetails_Header, and the new group footer OrderDetails_Footer.

  6. Click the Detail (Orders_Detail) section to select it. On the Properties window, change the section's name to Products_Detail.

  7. Using the mouse, drag the OrderDate field from the Detail (Products_Detail) section to the Orders_Header section.

  8. From the Data Environment designer, drag the ProductName field (under the Products command) into the Detail (Products_Detail) section.

  9. Delete the Label control named Label1.

  10. Resize the group headers, and rearrange the text box controls to resemble the figure below.

    The figure above requires some explanation. First, the Group footers are all closed in order to take up the least possible space. Like the Details section, any additional space left in any header or footer will be multiplied in the final report. Therefore, if a header or footer doesn't contain any fields, you can close the distance between the headers or footers.

    The Group Header named OrderDetails_Header is also closed. If you wonder why no fields are being shown, you must understand that the Order Details table in the Northwind database is a join table—the table contains only the IDs of records from the Orders table joined to IDs of records from the Products table. Thus the Order Details table doesn't contain fields which are actually displayed. Instead, it functions only to join two other tables. In the Data Report designer, the Order Details table therefore functions only to create groups of records—the product names grouped under the order dates.

    Finally, the Details section contains only the names of products. The Details section contains the innermost level of repeating records.

  11. Save and run the project.

Step by Step

This topic is part of a series that walks you through creating a sample data report.

To See
Go to the next step Adding a Calculated Field to the Data Report
Start from the beginning Creating a Simple Data Report