Previous | Table of Contents | Next

Page 377

can place a button item next to the text item. This button is reduced in size, and makes the item appear to be a pick list. The users like this feature because when they see the button, they know it will open a list of some sort by simply clicking the button.

FIG. 14.36
The DEPT LOV used to
return values to the
fk_department item.



To create the button on the form, perform the following:

  1. Open the Layout Editor.

  2. Select the push button tool from the tool palette. This will change the cursor to a cross-hairs.

  3. Select a spot and click the left cursor button. This will place a default button on the canvas.

  4. Resize and position the button using the drag handles. Place it after the fk_department item.

  5. Double-click the button to open its property sheet.

  6. Change the label to a pipe symbol `|'.

Figure 14.37 shows the button on the Layout Editor after these changes have been made.

FIG. 14.37
The layout editor
containing the
reformatted LOV button.



Page 378

The final step is to create a trigger that will be activated when the button is clicked. This will require a When-button-pressed trigger to be assigned to the button. We will discuss creating triggers in the next section. Figure 14.38 displays the text of the trigger.

  1. Open the Object Navigator and locate the button. Make sure it is on block ONE and follows the fk_department field. This will ensure proper tabbing order. If you need to move the button, select the button and drag it to the proper location on the Object Navigator.

  2. Expand the button object to expose its triggers child object.

  3. Press the create button on the Tool Palette. The Triggers dialog box will appear.

  4. Select the when-button-pressed trigger. Press OK. The PL/SQL editor will appear.
    Enter the PL/SQL script contained in Figure 14.38. Press the compile button to ensure no errors exist.

  5. Close the PL/SQL editor. Generate and run the application.

FIG. 14.38
The When-Button-
Pressed PL/SQL
statements that cause
the display of the LOV.



The script causes the form to shift the input focus to the fk_department item on block ONE. After changing the focus, it displays the LOV linked to the fk_department item.

Modifying the Record Group

Occasionally, it is necessary to modify the record group. This occurs when the developer wants to add another column to a LOV. Modifying the Record Group Query property changes the query. The record group property sheet is displayed in Figure 14.39. When the Record Group Query is selected, the property sheet will display a yellow button at the top of the sheet. Clicking this button opens an edit window that can be used to modify the query. Clicking the OK button will cause forms to compile and validate the query. It may then be used to modify or create a LOV.

Understanding Relation Properties

When the developer creates a master/detail form, Forms creates an object called a relation, a child object of the master block. It contains the conditions that relate the two blocks. Generally it is not necessary to use this object. However, sometimes the join condition needs to be

Page 379

modified. Changes in the database tables or possibly an error by the developer may cause this. Rather than dropping the detail block it may be easier to modify the Join Condition property of the relationship. Figure 14.40 displays a relationship property sheet.

FIG. 14.39
The record group
property sheet and the
record group query edit
window.




FIG. 14.40
The relationship
property sheet for block
ONE and block TWO of
the Employee Update
form.



Summary

Forms often contain records from multiple tables. The records from the two tables are related in a master detail relationship. Forms enables the developer to add blocks related to existing blocks. Using the master-detail tab of the New Block dialog does this. The chapter discussed the creation of two detail blocks for the Employee Update form.

The form object has a number of properties or attributes. The coordinate information setting determines the coordinates used in the Forms designer to place objects. The current record attribute uses a visual attribute to change the look of the current block record. The menu property is used to identify the menu used by the form. The cursor mode determines the navigation range of the cursor.

The block object also has a number of properties. The base table property contains the name of the table or view. The delete allowed, insert allowed, and query allowed settings determine whether these functions can be performed on the block. The navigation style determines where the cursor navigates after tabbing from the last item. The order by and where clause properties order the records and limit the number selected. The records displayed property determines the number of record displayed by the form.

Page 380

There are eleven types of items that can be displayed on the canvas: push button, check boxes, chart items, display items, images, list items, OLE containers, radio groups, text items, user areas, and VBX controls. The items contain a variety of properties. The alignment property control justification. The Font properties control the text format. The LOV property determines the LOV used for the item. The required property determines whether the item must have a value. The Multi-Line property is used to enable the user to enter text on multiple lines of the item.

A LOV is an item that can be used to display a dialog box that displays values for the item. The LOV can be used to validate values entered into the item. A relationship is an object that contains the conditions of the join between a master and detail block.

From Here...

The next chapter covers triggers. Triggers are events that execute PL/SQL code. The chapter describes how to incorporate triggers into the form. It also covers the PL/SQL editor. It is the tool used to write the PL/SQL. The chapter also covers built-in subprograms, system variables, global variables, and alerts. The last part of the chapter describes a template security scheme that can control who updates a form.

Review Exercises

Use the a_13_02.fmb to perform these exercises.

  1. Add a tools and glasses block to the Employee Update form. Be sure to include a button palette. Format the blocks.

  2. Create a visual attribute that has a red foreground color. Use this attribute to denote the current record in the tools and glasses block.

  3. Create a LOV for the fk_department field in block ONE.

  4. Create a button that displays the LOV.
    Change the payroll_deduct item on the tools block to a check box.

  5. Change the gender item on block ONE to a radio group.

  6. Change the state field on block ONE to a poplist item.
    Place a button on canvas that will call up the employee photo. The files are located on the CD and have the following filename format: paryoll_number||emp.pcx.

Previous | Table of Contents | Next