Previous | Table of Contents | Next

Page 424

Now you can create the detail query by following these steps:

  1. Click the SQL tool from the vertical toolbar. Initially, this query will be named Q_1 because you renamed the master query.
  2. Double-click query Q_1.
  3. Change the name of the query to Q_INSTRUCTOR.
  4. Click the button labeled Tables/Columns.
  5. In the Table and Column Names window, scroll down to the INSTRUCTOR table and select it.
  6. Select each of the columns in the Columns listbox.

To use the selected table and columns in the query's SELECT statement, follow these steps:

  1. Click SELECT-FROM and CLOSE.
  2. Rearrange the column names in the SELECT statement so that they're in the order that you want to see on the report: Department_ID, Instructor_ID, Last_Name, First_Name, MI, Position.
    Even though Department_ID is already part of the master query, it's also needed in the detail query so that the two queries can be joined based on the common column.
  3. Also, add an ORDER BY clause to the SELECT statement so that the rows will be ordered by Last_Name, First_Name, and MI, as shown in Listing 15.1.
  4. Click OK to return to the Data Model Editor.

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.

Specifying a Default Layout

Now that you've created the data model for the master-detail report, the next task is to specify the report layout.

  1. Invoke the Default Layout dialog window by either clicking the green triangle on the horizontal toolbar or by selecting Tools | Default Layout from the menu.
  2. In the Style tab folder, select the Master/Detail style (see Figure 15.20).

Figure 15.20.
Specifying Master/
Detail report style.

Page 426

  1. Select the Data/Selection tab folder. You can change a label in the Data/Selection tab folder. For example, you can reduce the width of a field or abbreviate its name, as shown in Figure 15.21.
  2. Click OK to generate the default layout for the report.

Figure 15.21.
Modifying labelsand
field widths.

The resulting layout needs to be modified.

  1. Using the Object Navigator, delete the detail column heading for Department ID.
  2. Delete all the lines beneath the column headings.
  3. In the Layout Editor, reposition all of the fields so that they're aligned with the column headings and with each other.
  4. Change the fonts for all objects to MS Sans Serif, Normal, 12 points.
  5. Change the column labels and headings to Bold. Figure 15.22 illustrates what the report layout should look like.

There's one more thing that needs to be changed. The detail frame—Q_INSTRUCTOR—contains 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

  1. To hide this field, double-click F_Department_ID1 in the detail frame. A window appears in which you can specify that the field should be hidden is displayed (see Figure 15.23).
  2. Check the field labeled Hidden.
  3. Click OK.

Figure 15.22.
Completed layoutfor
master-detail report.

Figure 15.23.
Hiding the Depart-
ment ID in the detail
group.

Page 428

Testing the Report

This section walks you through testing the master-detail report.

  1. Click the green light on the horizontal toolbar.
  2. In the Runtime Parameter Form, click Run Report. The Report Progress window displays the activity that's occurring on both the client and the server. Shortly, you will see the first page of the report as shown in Figure 15.24.
  3. Click Close when you're finished reviewing the report. If you like, you can save this report in the application directory as Dept_Instructor.rdf.

Figure 15.24.
The first page of
Master/Detail report
is displayed.

Generating a Runtime Version of a Report

To run a report from a forms application or from a shortcut on the Desktop, you need to generate a runtime version of the report—which 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

Using a Format Trigger

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 modified—sz_attr—which represents the field's font size. The second line sets the font size

Previous | Table of Contents | Next

Используются технологии uCoz