Page 476
Figure 17.20.
Selecting the repeater's
primary panel.
Select the text field tool on the Object Palette, and create a text field by clicking within the primary panel of the repeater. Create a total of six text fields. For each text field, do the following:
As an example, Figure 17.21 displays the property sheet for the Class_ID text field.
Once you have specified the properties for each of the text items in the repeater's primary panel, add a heading to each column by selecting the static text tool on the Object Palette and placing a static text object above the repeater text field. When you have finished, test the form by right-clicking Run Form. Figure 17.22 illustrates what your form should look like when it displays the classes for the psychology department. Exit test mode, and open the Student form for the next exercise.
Page 477
Figure 17.21.
Property sheet for a
text field within the
repeater's primary
panel.
Figure 17.22.
Testing the Master/
Detail form.
Let's look at two other objects that you can incorporate in your forms: the radio button frame and the radio button. A radio button frame typically contains two or more radio buttons. For example, suppose you wanted to modify the Student form by incorporating the student's year displayed as a group of radio buttons.
Page 478
The first step is to add a radio button frame to the form.
Figure 17.23. Page 479 Figure 17.24.
Adding a radio button
frame to a form.
DataSource
Year (the column that is represented in the radio
buttons contained by the radio button frame)
Datatype
String
FontBold
True
FontName
MS Sans Serif
FontSize
10
Label
Year
Name
StudentYear
Specifying the radio
button frame properties.
NOTE
You cannot name the radio button frame "Year" because it is an
Oracle Basic reserved word.
The next step is to add four radio buttons to the radio button frameFreshman, Sophomore, Junior, and Senior. To add a radio button, select the radio button icon from the Object Palette (it's in the left column, third from the top). Position the pointer inside the radio button frame and left-click. Your form should look like the one displayed in Figure 17.25.
You'll need to set the properties for the radio button by left-clicking Properties. For the first radio button, you'll want to set these properties:
DataSource | Year |
Datatype | String |
Label | Freshman |
Name | Freshman |
ValueOn | FRESHMAN (this property contains the value that is actually stored in the column when the radio button is set) |
Page 480
Figure 17.25.
Figure 17.26 displays the Property Sheet for the radio button. When you have finished
setting the properties, close the Property Sheet. Perform the same steps to add radio buttons
for Sophomore, Junior, and Senior. When you are finished, your form should look similar to
the one displayed in Figure 17.27.
Figure 17.26. Page 481
Figure 17.27. Try testing the modified Student form. As you can see in Figure 17.28, the student's year
is displayed in the correct radio button.
Figure 17.28. You will often need to add a lookup field to a form. Power Objects provides a
built-in function named SQLLOOKUP that is used to execute a query and return a single column. As
an example, let's look at the DepartmentClass form. Suppose that, in addition to the
department ID, you also want to display the number of courses that the department offers.
Page 482 Figure 17.29. As you can see, the function SQLLOOKUP contains two arguments. The first
argument is the database session, and the second argument is the SELECT statement to be executed via the database session. In this example, the SELECT statement will return the number of courses from the Course table in which the Department_ID column is equal to the value currently displayed in the Department_ID text field.
Adding a radio button
to the radio button
frame.
Setting properties for
the Freshman radio
button.
Student form with
radio button frame
and four radio
buttons.
Testing the form with
the radio button
frame and four radio
buttons.
Displaying a Lookup Field
Adding a text field
that will display a
lookup value.
DataSource =sqllookup(flugle,"select count(*) from course where
department_id = `" + department_id.value + "`")
Datatype Long Integer
Name NumberOfCourses
ReadOnly True
NOTE
If you set the DefaultSession property for an application, you don't have to specify the database session when invoking SQLLOOKUP, unless you want to use a different database session.