Previous | Table of Contents | Next

Page 423

displayed, the employee's records will appear. The user will not have to enter search criteria to retrieve the employee's record.

The following are the tasks to create a new button on the Button Palette called "Main Rec," that will display the Employee Update form.

  1. Open the directory's layout editor and select any of the existing buttons.

  2. Place a copy of the button in the clipboard by selecting Edit, Copy, Menu option.

  3. Place a copy of the button on the form by selecting Edit, Paste.

  4. Drag the new button to the right side of the button palette.

  5. Open the button's property sheet by double-clicking the button.

  6. Change the Name property to "main" and the Label property to "Main Rec." Close the property sheet.

  7. Open the PL/SQL editor for the button's When-button-pressed trigger. This is done by selecting the button and select the Tools, PL/SQL Editor menu option. Enter the code shown in Figure 16.14 into the trigger.

FIG. 16.14
The Main Rec button's
When-button-pressed
code block.




The purpose of the global.directory variable in the trigger is to let the Employee Update form know it was called from the directory. A When-new-form-instance trigger will evaluate this variable and execute a query if the value is Y. The trigger will place the form in the Query mode if the variable does not have a value of Y.

TIP
I generally place a When-new-form-instance trigger on all non-directory forms that I create. I believe that the user goes to the form to query an existing record more often than to enter a new record. Thus the user will want to use the Query mode more often than the Input mode. Using the trigger to place the form in the query mode saves the operator the task of pressing the query button upon entry.

The next step is to place a form level When-new-form-instance trigger in the Employee Update form (EMPCH16.FMB on the CD). Figure 16.15 shows the code block used in the trigger. The major component of the code block consists of an if-then-else statement. If the form was called from the directory, the global.directory variable will be a Y. The global.pay_num variable is populated with the payroll number of the directory record currently selected. The value of

Page 424

this variable is transferred to a form variable and a query is executed. If the application was not called from the directory, the value of global.directory will not be a Y. The trigger will place the form in the Query mode.

NOTE
You may place this trigger into the EMPCH16.fmb form in you are practicing the modifications. Be sure to generate this form when done.

FIG. 16.15
The When-new-form-
instance trigger that
is fired when the
Employee Update form
is opened.




You may have noticed that the third line of the trigger referenced a variable on block four. This is the name of a nonbase table block created for the form. A form that automatically retrieves records when called must have a nonbase table block to hold search values. The reason is that forms are initially opened in the input mode. Placing the form into the query mode causes Forms Runtime to clear any values on the form. When the execute_query subprogram is issued to a block in the input mode, the form is still placed temporarily in the query mode. This precludes placing the global.pay_num variable directly into the payroll_number field. The value will be cleared before the query can be executed.

The value also cannot be placed into a block that contains a base table. Placing a value into this type of block will cause the form to think the block has been updated. The form will then try to commit the change before the form can be closed or a query performed. Therefore, any values supplied to a form from another form must be placed in a nonbase table block. This can be a special block such as block four or the button palette block.

One final problem exists in the technique. The value contained in the nonbase table block must be placed in the master block after the block is placed in the query mode and before the query is executed on the block. This is done by using the Copy Value from Item property. This property ensures that the value in the item is always the same as the item specified in the property. Thus, the When-new-form-instance trigger populates the payroll_number item on block four. The trigger then issues the execute-query subprogram. Forms Runtime then places block one in the query mode. The Copy Value from Item setting move the value from the payroll_number item on block four into the payroll_number field on block one. The query is then executed by retrieving the records into the form.

Page 425

Before closing the Employee Update form, an Exit button should be placed on the form by using the same procedure described in the Employee Directory section. This button will close the form and return the operator to the directory.

Figure 16.16 displays the Employee Directory with the new Main Rec button. The directory is displaying the employee records. To select a record to display when navigating to the Employee Update screen, click on any of the items on a row. In Figure 16.16 the record for Truman is selected.

FIG. 16.16
The Employee Directory
with Truman's record
selected.




Pressing the Main Rec will cause the Employee Update form to appear with Truman's records displayed. Figure 16.17 shows this form.

FIG. 16.17
The Employee Update
form after it has been
called from the
Employee Directory.




Pressing the Exit button on the Employee Update form will return the operator to the Employee Directory.

Page 426

NOTE
You may try this by using your modified forms. If you have not created a form, you may launch the DIRCH16.FMX executable code file from Forms Runtime. The file is located on the CD.

Creating and Using Menus to Combine Applications into a System

Most applications are part of a group of applications called a system. One of the bigger systems I have seen is the T and D Equipment System. This system contains numerous forms and reports. It contains information on distribution transformers, cable terminal poles, padmount switches, substation transformers, breakers, relays, and regulators. Each of these equipment entities has between five and 25 forms. Some of the forms generate numbers. Some of the forms are directories and some of the forms are used to maintain the records. The forms and reports have one thing in common: They are combined in a system through the use of a common menu.

The T and D Equipment System has one menu located at the top of the screen. This menu is used by each of the applications in the system. It contains a selection for each of the applications in the system. Each equipment entity is listed on the menu bar. The entity has a pull-down menu list that displays each of the applications that pertain to the entity. This gives the operator the ability to move from a breaker form to a cable terminal pole form by selecting a new menu option. More important, it gives the operator one common, simple access method to over one hundred applications.

Creating a Menu

A menu is an Oracle Forms module with a source code file extension of .MMB. Menus are created in Forms Designer on the Object Navigator. To create a menu, follow these steps.

  1. Open the Object Navigator and locate the menus module object.

  2. Select the menus module object and click the create icon. Forms will create a new menu module or file.

    Figure 16.18 displays the Object Navigator after the menu module has been created.

  3. The next step is to select the menus object and click the create icon.

    This step will create a menu object, as shown in Figure 16.19.

    To the left of the menu object is a pull-down menu icon.

  4. Double-click this button to open the Menu Editor dialog box, as shown in Figure 16.20.

The box is a screen painter used to lay out the menu.

At the top of the menu editor are a series of buttons and a picklist. The picklist is used to select or change menu objects.

Previous | Table of Contents | Next