Previous | Table of Contents | Next

Page 471

Figure 17.14.
Setting the FontSize
and FontBold
properties for multiple
static text objects.

Figure 17.15.
Form with text fields
and headings.

Testing the Form

The Power Objects Designer provides a convenient method for testing a single form (it is very similar to the same feature provided in Oracle Forms). To run the current form, you can right-click Run Form or click on the Run Form button on the toolbar (appropriately, it resembles a lightning bolt striking a form). If you've made any changes to the form since it was last saved, Power Objects Designer will ask you to confirm that you want to save the changes that you have made. After you click Yes, the Power Objects Designer will run the

Page 472

form. As you can see in Figure 17.16, the fields contain a record from the Student table. However, there is no way to navigate to the next or the previous record! Exit test mode either by clicking the Terminate button (which resembles a red traffic signal) or by closing Form1.

Figure 17.16.
Testing the form—the
form retrieves a record
from the Student
table.

Adding a Scrollbar to the Form

Power Objects provides an easy way to add navigation to a form. From the Object Palette, select the horizontal scrollbar icon and left-click on the form where you want the scrollbar to appear. Reposition and resize the scrollbar as you like.

Now, test the form again by right-clicking Run Form. Try navigating to the next and previous records by clicking each end of the scrollbar. As you can see, you were able to add the scrollbar to the form without setting any properties or writing any code.

There are some other features that Power Objects provides that are "freebies"; for instance, you can run a query by selecting Database | Query by Form from the menu. Another window, titled "Find What?" will appear. If you want to find all students whose last name begins with an A, enter A% in the Last Name field in the Find What? form (see Figure 17.17). To execute the query with the search criterion, select Database | Apply Form Query. You will find two students who satisfy the criterion—Anna Anastatia and Kenneth Abbot. You can also update a record, insert a record, and delete a record by right-clicking the mouse and selecting the appropriate menu item. Exit the form to return to design mode.

Specifying the Retrieval Order for the Form

You'll want to specify the order in which the records are retrieved and displayed on the form. As you recall, the form should present the records from the Student table ordered by last name and first name. Select the form, and right-click Property Sheet. Scroll down to the OrderBy property and enter Last_Name, First_Name. Once again, try testing the form. The records should be presented in the order that you specified: Last_Name, First_Name.

Page 473

Figure 17.17.
Enter a search
criterion in Query by
Form.

Naming the Form

Unlike Oracle Forms, Power Objects doesn't save a form in its own file; a form is saved as part of the application object. To change the name of the form to Student, set the Label property to Student and the Name property to frmStudent.

Creating a Master-Detail Form

Creating a master-detail form in Power Objects is easy. As an example, let's create the Department Class form that you created using Oracle Forms. To begin, create a new form in the Flugle application object.

First, you're going to create the objects that are associated with the master table, which is Department.

  1. Select the form by clicking it, and right-click Property Sheet.
  2. Set these properties for the form:
    	Name              frmDepartment_Class
    
    	RecSrcSession     Flugle
    
    	RecordSource      Department
    
    	OrderBy           Department_ID
    
  3. Exit the form property sheet.
  4. Select the text field icon from the Object Palette, and place the text field in the upper portion of the form.
  5. Right-click Property Sheet, and set the DataSource and Name properties to Department_ID. Also, you'll need to set the Datatype property to String (by default, it is set to Long Integer).

Page 474

  1. Exit the text field property sheet.
  2. Select the static text tool from the Object Palette, and place a text label to the left of the Department_ID text field.
  3. Set the name of the label to Department; change the FontBold property to True and the FontSize property to 10.
  4. Finally, you'll need a scrollbar to navigate between departments. Select the horizontal scrollbar tool from the Object Palette, and create the horizontal scrollbar on the form just below the Deparment_ID text field.

At this point, your form should look like the one displayed in Figure 17.18.

Figure 17.18.
Master portion of the
form.

Next, you're going to create the detail portion of the form. Select the repeater tool on the Object Palette—it is in the right column, fourth from the bottom, and looks like a gray form with white borders. Place the repeater on the form beneath the Department_ID text field. The repeater will be used to display the detail records from the Class table that correspond to the currently displayed Department_ID. A repeater is a container that is composed of these elements:

Frame This is the object that encloses the entire object.
Primary panel This is the panel at the top of the repeater in which you place other controls and static objects. Typically, the primary panel is where you place the text fields that will be displayed in the repeater.
Secondary panel These are the panels that display additional instances of the objects that are contained in the primary panel.
Scrollbar The repeater contains a vertical scrollbar on its right side.

Page 475

Once you've placed the repeater on the form, right-click Property Sheet. There are several properties that you need to set for the repeater to function properly:

RecordSource Class (this is the table from which the records are retrieved)
RecSrcSession Flugle (this is the database session to be used in accessing the database)
LinkDetailColumn Department_ID (this is the name of the column in the detail recordset that will be used to link to the master recordset)
LinkMasterColumn Department_ID (this is the name of the column in the master recordset that the detail recordset will be linked to)
LinkMasterForm DepartmentClass (this is the name of the form that contains the master records)
OrderBy Class_ID (the column/columns that should be used in ordering the detail records)

Figure 17.19 displays the property sheet for the repeater. Close the repeater property sheet.

Figure 17.19.
Property sheet for the
repeater.

Next, you need to add the text fields to the repeater's primary panel. Select the primary panel as illustrated in Figure 17.20.

Previous | Table of Contents | Next

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