Previous | Table of Contents | Next

Page 418

Creating the Employee Directory

Take the following steps to create an Employee Directory:

  1. The first step in creating the employee directory is to create a new form module.

  2. Select the Blocks object and press the create icon. This will open the New Block Items dialog box.

  3. Change the Base Table value to Employee and the Block Name value to one.

  4. Click the Items tab.

  5. Press the Select Columns button to display the items.

  6. Select the following items: payroll_number, last_name, first_name, employment_date, birth_date, current_position, fk_department, and gender. Format the labels to suit your needs.

  7. Click the Layout tab.

  8. Change the Style property to "form." The orientation should remain "vertical" and Records equals 1.

  9. Click the OK button to create the default block.

  10. Open the Layout Editor and select the Edit, Select All menu option.

  11. Double-click one of the text items to open a multi-item property sheet. Be sure the Union property sheet tool is activated. Change the Base Table property to "false" and the Case Restriction property to "Upper." Close the property sheet.

  12. Place and format the block one items.

  13. Open the Object Navigator. Open the block-one property sheet. Change the Base Table property to "false." Close the property sheet.

  14. Change the tab order of the items by dragging them. The tab order is from left to right, top row to bottom row.

    Figure 16.7 shows block one of the Employee Directory.
    Create the display block.

  15. Open the Object Navigator and select the Blocks object.

  16. Click the Create tool. This will open the New Block options dialog box. The Base Table value is "employee" and the Block Name is "two."

  17. Click the Items tab. Click the Select Columns button to display table columns. The columns that will be displayed and all search columns must be selected. Select the following fields: payroll_number, last_name, first_name, employment_date, birth_date, current_position, fk_department, gender, wages, and phone. Delete the labels for the birth_date and gender fields.

  18. Click the Layout Tab. The Style setting will be "tabular." The Orientation is "vertical." The value for the Records setting is 10. The Button Palette and Scrollbar check boxes should be checked. Press the OK button to create the display block.

Page 419

FIG. 16.7
Block one of the
Employee Directory.




  1. Open the canvas property sheet. Change the Width property to "592" and the Background to "r50g100b50."

  2. Open the Windows object property sheet. Set the Width property to "592" and the Title property to "Employee Directory."

  3. Open the Layout Editor and format the items on the canvas.

    Figure 16.8 shows the canvas at this point. The block two fields stretch beyond the edge of the canvas.

FIG. 16.8
The Block two fields
before formatting.




  1. Select Edit, Select All menu option. Change the font for all canvas objects to MS San Serif, Bold, 10.

Page 420

  1. Select the birthdate and gender items. Open the multi-item property sheet and change the Canvas property to Null and the Display property to "false." This will cause the items to disappear from the canvas.

  2. Format the remainder of the items to suit.

    Figure 16.9 shows the canvas after it has been reformatted.

FIG. 16.9
The Employee Directory
after formatting.




  1. Select all of the display items on block two.

  2. Double click any of the selected items to open a multi-item property sheet. Change the Required property to "false," the Insert Allowed property to "false," and the Update Allowed property to "false."

    Figure 16.10 displays the property sheet with the settings.

FIG. 16.10
The multi-item property
sheet used to set the
block two common
properties.



Page 421

  1. Select each of the items on block two that have a corresponding search field on block one. These items consist of payroll_number, last_name, first_name, fk_department, employment_date, birth_date, current_position, and gender. Place the name of the corresponding bloc-one search field into the Copy Value from Item property.

    Figure 16.11 shows the property sheet and Copy Value from Item property for the payroll_number item.

FIG. 16.11
The Payroll_number
item property sheet
and the value for the
Copy Value from
Item property.




    The next step is to create a form-level Key-entqry and Key-exeqry trigger. These triggers will cause all queries to be performed on block two. Figure 16.12 shows the Key-entqry code block. This same code is in the Key-exeqry trigger and the When-button-pressed trigger for the Query button.


  1. Create a Key-entqry form trigger that contains the trigger script contained in Figure 16.12.

  2. Create a Key-exeqry from trigger that contains the trigger script containe in Figure 16.12.

  3. Modify the When-button-pressed trigger for the Query button. Replace the trigger script with the script contained in Figure 16.12.

FIG. 16.12
The Key-entqry trigger
code block used
to perform queries
on block two.



Page 422

    Although at this point the directory is operational, one additional task should be performed. Place an exit button on the form. Because this form does not need a Save button, this button can be changed to an Exit button. To do so:


  1. Open the Layout Editor and double-click the Save button. This will open the button's property sheet.

  2. Change the Name property to "Exit" and the Label to "Exit."

  3. Open the button's When-button-pressed trigger and change the code block to "exit_form."

    The directory is now ready for operation.

  4. Generate and run the directory.

Operating the Employee Directory

Figure 16.13 shows the completed Employee Directory. A directory is simple to operate. The top block contains the search criteria. The operator can enter a value in any of the search fields. Pressing the F7 or F8 function keys or the Query button will cause a query to be executed on block two. Figure 16.13 displays the Employee Directory as it displays the results of a query based upon search criteria entered into the last_name field.

FIG. 16.13
The Employee Directory
displaying the results of
a query.




Calling Other Forms from the Employee Directory

The purpose of a directory is to identify records. Directories by their nature can display only a small amount of a record's data. In order to aid the operator in viewing additional information, buttons can be placed on the directory to call forms that display additional information about the entity.

To illustrate this technique, a button will be placed on the Employee Directory. Pressing this button will cause a trigger to fire that calls the Employee Update form. When the form is called, the employee's payroll number will be transferred to the called form. When this form is

Previous | Table of Contents | Next