Previous | Table of Contents | Next

Page 504

Figure 18.20.
Properties for the
Department_ID field
in the GroupHeader
area.

Specifying the GroupHeader Area

A Group area is used to "break" the report output. For this sample report, you want the report to "break" whenever the department changes so that a new column heading for department is printed.

  1. Select the Text Field button on the Object Palette, and click in the GroupHeader area. Right-click Property Sheet to set these properties for this text field (see Figure 18.21):
    DataSource Department_ID Datatype String DrawStyle Standard Control (assuming that you don't want a report item to appear recessed) HasBorder False (assuming that you don't want a border around report items) Name Department_ID

  2. Exit the property sheet.
  3. On the report, add a label for the Department_ID field by clicking the Static Text button on the Object Palette and clicking to the left of the Department_ID text field.
  4. Set the properties for the static text such as Name and FontBold.

Page 505

  1. Also, you need to set a property for the GroupHeader band itself.
  2. Select the GroupHeader band, and right-click Property Sheet.
  3. There is a single property you need to set—GroupCol—which should be set to Department_ID.

There is another property you may want to set for some reports: PageOnBreak. By default, this property is set to False, meaning that Oracle Objects will not go to the next page when there is a new value for Department ID. If you do want this behavior, set PageOnBreak to True.

Figure 18.21.
Properties for the
Department_ID field
in the GroupHeader
area.

Specifying the Detail Area

You still need to add three objects to the Detail area: the course ID, the course title, and the course description. These will all be text fields. To add these three objects to the Detail area, select the Text Field button on the Object Palette, and add three text fields in the detail area.

Select the first text field, invoke its property sheet, and set these properties:

	DataSource     Course_ID

	Datatype       String

	DrawStyle      Standard Control

	HasBorder      False

	Name           Course_ID

Page 506

Select the second text field, invoke its property sheet, and set these properties:

	DataSource     Title

	Datatype       String

	DrawStyle      Standard Control

	HasBorder      False

	Name           Title

Select the third text field, invoke its property sheet, and set these properties:

DataSource     Description

Datatype       String

DrawStyle      Standard Control

HasBorder      False

Name           Description

However, there are two other properties that you must specify for the Description field:

DataSize 2000 (this allows the field to accommodate the contents of the Description column, which can be up to 2000 characters) Multiline True (this allows the Description field to wrap to multiple lines, as needed)

Close all the property sheets. At this point, your report should look much like the one displayed in Figure 18.22. Try testing the report by right-clicking Run Form. Figure 18.23 illustrates what the finished report looks like.

As you can see, the courses appear below the department that offers them. Also, notice that the Run-Time mode toolbar for a report is different from the Run-Time mode toolbar for a form. In the upper-left corner, there are two buttons that will go to the previous or next pages in the report. To exit Run-Time mode, click Stop on the toolbar.

Page 507

Figure 18.22.
Final report layout.

Figure 18.23.
Testing the report.

Page 508

Adding a Lookup Field to a Report

As with forms, you can add a lookup field to a report. For example, suppose you want to add a field to the Flugle College Course Catalog that indicated whether or not a course was offered—in other words, whether or not it was in the Class table. To do this, add a text field to the Detail area of the report. Invoke the property sheet for the new field. Set these properties:

	Datatype     String

	DrawStyle    Standard Control

	HasBorder    False

	Name         Offered

As shown in Figure 18.24, set the DataSource property to:

=sqllookup(Flugle,"select decode(count(*),0,null,'Offered') from Class
where Department_ID = `" + Department_ID.value +
Â"' and Course_ID = `" + Course_ID.value + "` ")

Figure 18.24.
Setting the properties
for a report lookup
field.

Let's examine this statement. The SQLLOOKUP function is used to execute a SELECT statement against the Flugle database session. The SELECT statement uses the DECODE function to decode the value count(*), which is the number of classes that have the same value as the Department ID and Course ID fields. If count(*) is equal to 0, the DECODE function will return null; nothing will appear in the report. If count(*) is not equal to zero, this means that there are

Page 509

classes offered for this department and course, and the DECODE function will return the string Offered.

Let's test the revised report. Click on Run Form on the toolbar. On the first page of the report, scroll down to the courses offered by the Biology department. As you can see in Figure 18.25, BIO 101 is offered this semester.

Figure 18.25.
Testing the lookup
field in the report.

Summary

In this lesson on Power Objects, you learned these important concepts:

Previous | Table of Contents | Next

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