Page 424
Now you can create the detail query by following these steps:
To use the selected table and columns in the query's SELECT statement, follow these steps:
Listing 15.1. The detail query's SELECT statement.
Select Department_ID, Instructor_ID, Last_Name, First_Name, MI, Position from Instructor order by Last_Name, First_Name, MI;
When you defined the SELECT statement for the query, the Reports Designer created a group for the master query: G_INSTRUCTOR.
To join the master query to the detail query, select the data link tool from the vertical toolbar. Place the pointer over Q_DEPARTMENT, hold down the left-mouse button, drag the pointer over Q_INSTRUCTOR, and release the mouse button. The Data Model Editor should create a link between Q_DEPARTMENT and Q_INSTRUCTOR, using Department_ID (see Figure 15.19).
Page 425
Figure 15.19.
Master query is linked
to detail query.
Now that you've created the data model for the master-detail report, the next task is to specify the report layout.
Figure 15.20. Page 426
Specifying Master/
Detail report style.
Figure 15.21.
Modifying labelsand
field widths.
The resulting layout needs to be modified.
There's one more thing that needs to be changed. The detail frameQ_INSTRUCTORcontains Department_ID so that the detail query can be linked to the master query. But it would be redundant to display Department_ID in the detail frame because it's already displayed in the master frame.
Page 427
Figure 15.22.
Completed layoutfor
master-detail report.
Figure 15.23. Page 428
Hiding the Depart-
ment ID in the detail
group.
This section walks you through testing the master-detail report.
Figure 15.24.
The first page of
Master/Detail report
is displayed.
To run a report from a forms application or from a shortcut on the Desktop, you need to generate a runtime version of the reportwhich is an REP file. While you have a report open in the Reports Designer, you can generate a runtime version of the report by pressing Ctrl+t or by selecting File | Administration | Generate from the menu. By default, the Reports Designer assumes that you want to use the same name for the REP file that you used for the RDF file.
Page 429
There are many things that you can do to customize a report with Reports Designer. For example, you can specify a format trigger for a field so that the field's appearance depends on its contents. Let's explore an example using the master-detail report that you constructed.
Suppose you want the report to emphasize when an instructor is a professor by increasing the font of the Instructor ID field. To do this, double-click the field named F_Instructor_ID. In the window that is displayed, select the General Layout tab folder. In the lower-left corner of the General Layout tab folder, click the key labeled Edit. The Program Unit Editor is displayed; by default, the editor displays a function named F_Instructor_IDFormatTrigger. The layout field properties window will still be displayed. Reposition it so you can modify the function as shown in Figure 15.25.
Figure 15.25.
Specifying a format
trigger for a layout
field.
The function makes use of a built-in package named SRW, which is used to modify the format characteristics of the field associated with the format trigger. Specifically, the if statement checks to see if the current value for the Position field is PROFESSOR; if so, the three calls to SRW are executed. The first line identifies the format attribute that's being modifiedsz_attrwhich represents the field's font size. The second line sets the font size