Previous | Table of Contents | Next

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.

Using Radio Buttons

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.

  1. Select the radio button frame icon on the Object Palette (it's in the right column, fifth from the top).
  2. Left-click on the form where you want to place the radio button frame (see Figure 17.23).

Figure 17.23.
Adding a radio button
frame to a form.

  1. Once the radio button frame is created, you can resize it by grabbing a corner and dragging it.
  2. Align it with the other fields on the form. Right-click Property Sheet to specify the properties for the radio button frame (see Figure 17.24). Specifically, you'll need to set these properties:


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

Page 479

Figure 17.24.
Specifying the radio
button frame properties.

  1. When you have set all the properties, close the property sheet.

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 frame—Freshman, 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.
Adding a radio button
to the radio button
frame.

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.
Setting properties for
the Freshman radio
button.

Page 481

Figure 17.27.
Student form with
radio button frame
and four radio
buttons.

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.
Testing the form with
the radio button
frame and four radio
buttons.

Displaying a Lookup Field

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

  1. Add a text field to the form (see Figure 17.29).

Figure 17.29.
Adding a text field
that will display a
lookup value.

  1. Set the properties for the new text field by right-clicking Property Sheet. You should set these properties as shown in Figure 17.30:
    DataSource     =sqllookup(flugle,"select count(*) from course where
                   department_id = `" + department_id.value + "`")
    
    Datatype       Long Integer
    
    Name           NumberOfCourses
    
    ReadOnly       True
    

    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.

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.

Test the form. As you can see in Figure 17.31, the NumberOfCourses field displays the correct value; if you check the contents of the Course table, you will see that there are three courses offered by the Anthropology department. However, the detail portion of the form is empty because none of the Anthropology courses is offered as a class this semester.

Previous | Table of Contents | Next

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