Page 399
NOTE |
I generally use alerts in security triggers or whenever the operator may be in danger of making a serious error. |
I have a form that generates sequentially numbered records. The form has a field for the number of records to generate. It is right next to a payroll number field. One day I placed my payroll number into the Number of records to generate field. I successfully generated 3,221 sequentially numbered records. I had to ask the DBA to delete the records for me. This error caused me to create an alert for the application prompting the operator to approve the generation of any number of records greater than 10.n
To illustrate an alert, the security trigger contained in the Pre-insert trigger in Figure 15.11 will be changed to display alerts rather than passive messages. The steps to create this alert are as follows:
Designer will create a sequentially numbered alert. Because the dialog box has two messages, two alerts are needed. The Object Navigator containing the two alerts is displayed in Figure 15.19. The alert object navigator icon is a red flag.
FIG. 15.19
The Object Navigator
listing the two alerts
and the alert property
sheet.
The alert property sheet is also contained in Figure 15.19. The Display Properties section controls the alert's title and color format, properties described in earlier chapters. The functional properties are peculiar to the alert. Table 15.1 contains a description of the various functional properties.
Page 400
Table 15.1Alert Functional Properties
Property | Description |
Alert Style | Determines the style of alert. Three styles are available: Stop, Caution, and Note. Stop contains the picture of a stop sign, and indicates the highest degree of danger. Caution contains an exclamation mark (!) surrounded by a white circle. Note uses a small letter I surrounded by black a circle. This symbol represents the lowest degree of danger. |
Button 1 | Contains the label for the first button on the alert. |
Button 2 | Contains the label for the second button on the alert. |
Button 3 | Contains the label for the third button on the alert. |
Default Alert Button | Identifies the default alert button. This button is normally formatted differently than the remainder of the buttons. |
The alert style for the security error messages is stop, which indicates the highest degree of danger. The alert can have more than one button, but this alert will have only one. Buttons 2 and 3 will not be displayed because their properties are Null. The message property contains the message that will be displayed in the alert. Alert1 will contain the message about not validating the password, and Alert2 will contain the second trigger error message.
Alerts are activated by the show_alert built-in subprogram. The subprogram is a function that returns a numeric constant. This constant is used to determine which of the three buttons was pressed. The value returned by the alert can be compared to the alert_button1, alert_button2, and alert_button variables. If the returned value is equal to the value of button_alert1, then button one was clicked . If the value equals alert_button2 or alert_button3 the clicked buttons were 2 or 3. The developer can assign a different set of procedures to each of the buttons clicked . This makes it possible to perform different procedures depending upon the value returned.
Because show_alert is a function it must be contained in an expression. Figure 15.20 displays the Form_security_checks procedure. This procedure was changed to use the show_alert function to display Alert 1 and Alert 2 rather than the messages. Your next steps are as follows:
Figure 15.21 contains the Employee Update form with the Alert1 dialog box displayed. It was displayed as a result of trying to update the Employee table.
Page 401
FIG. 15.20
The Form_Security_Checks
procedure after it was
modified to include
alerts.
FIG. 15.21
The Alert 1 dialog box
displayed as a result of
trying to update the
Employee table.
All forms and screens have one fundamental problem. The form has a defined height and width and the data viewed must fit within this space. To fit the space, you can lower the font sizes so additional data is displayed. Or you can place scroll bars on the windows so additional fields can be viewed by scrolling. I am not particularly fond of either method. There is a definite limit to the size a font can be reduced before the user can no longer read the screen. A technique that I have found and used extensively to solve this problem is to create a form with multiple canvases. The canvases can be displayed by clicking a button. This allows me to create a completely new view of the data.
To illustrate this concept, suppose the operator of the Employee Update screen wanted to see more than four Tools and four Glasses records at a given time but didn't need to see both sets of records at the same time. The Employee Update form cannot handle this request because there is not enough vertical height on the form to display increased amounts of Tools and Glasses records. To create additional space, the employee image and Glasses records can be placed on separate canvases, which would free up enough space to display 10 records.
The following steps can be used to create and display multiple canvases on the Employee
Update form.
The first step to modify the Employee Update form is to create two additional canvases.