Page 411
Forms EMPCH16.FMB and DEPCH16.FMB can be used to practice chapter examples. Forms EMPCH16A.FMB, EMPCH16B.FMB, and EMPSTART.FMB contain final examples.
In this chapter, many of the examples call one form or object from another. When you call an object, you must specify the full file path of the executable file. Because it is impossible to know the filepath you may be using for the follow-along practice, all examples and source code supplied have the filepath of the CD (d:). If you are developing these forms in Designer, or running them from Designer, you may want to change the default filepaths to the filepath you are using. You should also move the called files from the CD to your work directory. Be sure to generate the files in the directory you are using.
Executable files that contain the final modifications have been provided. You may use these to see the effect of the modications. The executable files (.FMX) provided on the CD cannot be loaded into Forms Designer. They must be run from Forms Runtime.
Page 412
A form or menu can call another form by using the call_form or the new_form built-in subprograms. The call_form subprogram takes the new application and overlays it on the original application. The original application is still available to the operator, but is not the current application. The new_form subprogram replaces the calling application with the called application. The calling application will no longer be available to the operator.
I generally use the call_form subprogram in systems that I develop. These systems have a startup application that is the central core of the system. The startup application is the first screen displayed in the system. Other applications are called from this screen. It is the place where the operator always returns when terminating the called applications.
My applications often have the capability to call another form. The reason is to view some additional information not available on the original form. I generally want to return to the calling form with all of its data intact to continue the work. The call_form subprogram enables the operator to return to the previous form with the data intact. Using the new_form subprogram the operator will have to call the previous form, enter the query data, and execute the query. This reduces the operator's productivity.
The one problem with the call_form subprogram is that users sometimes do not terminate the applications. They continue to call additional forms from the menu or from a form. These forms are still active and eventually the user will run out of memory on the PC. The operator usually learns to avoid this problem quickly.
The call_form subprogram launches another form while keeping the original form active. Figure 16.1 shows the call_form syntax and options. The form_name option is the only mandatory option. It contains the name of the form. The name should include the full file path. The display_type option consists of two values: hide and no_hide. The hide option will cause the called form to completely cover the parent application. It will cover the application even if it has a smaller window than the parent does. The no_hide option will allow parts of the parent application not covered by the child application to appear. A following subsection, "Using the Call_form Subprogram with the Hide and No_hide Options Specified," will demonstrate this feature.
The switch_menu option uses two values: no_replace and do_replace. The no_replace option keeps the menu used by the parent application. The do_replace option replaces the menu with the one specified in the child form menu property. The query_mode properties determine whether the child form can be run in the normal mode or in the query mode. The No_query_value setting causes the form to be run in the normal mode. The operator will be able to perform queries, inserts, updates, and deletes. The query_only option disables the form's capability to insert, update, or delete records. Finally the parameter_list option contains the name of a parameter list that will provide values to the child application.
Page 413
FIG. 16.1
Call_form syntax and
options.
The new_form subprogram activates a new application and terminates the original form. Figure 16.2 shows the syntax of the subprogram and its various options.
FIG. 16.2
New_form subprogram
and its options.
The form_name option contains the name of the child form. This is the only option that is mandatory. The rollback_mode option consists of three values: to_savepoint, no_rollback, and full_rollback.
The to_savepoint option will roll back all uncommitted changes to the last time a commit was performed. The no_rollback option exits the parent form with rolling back to a savepoint. The full_rollback rolls back all uncommitted changes that were made during the current Runform session. The query_mode option and the parameter_list option are exactly the same as the call_form options explained in the previous section.
Page 414
To call another form from an existing form, you must create an item and a trigger. The item can consist of a menu selection, a button on the form, or a button/icon on a tool bar. I generally use a button on the button palette block as the device to call the new form. In the following example, the Employee Update form (EMPCH16.FMB) will be modified to call the Department Update form (DEPCH16.FMB) by using a button. The Department Update form is a smaller form that does not completely cover the Employee Update form.
The first step is to create a new button on the Employee Update form. To do so, follow these steps:
FIG. 16.3
The When-button-
pressed trigger that
calls the Department
Update form.
The call_form subprogram calls the Department Update form. It does not have any options specified so it will hide the parent form. Figure 16.4 shows how the Department Update form will be displayed by using the subprogram in Figure 16.3.
Figure 16.5 contains the When-button-pressed trigger with the no_hide option specified. This will cause the Department Update form to partially cover the Employee Update form.
Figure 16.6 displays the Department Update form after it was called by using the no_hide option.
TIP |
In the preceding examples, the Department Update form was displayed with no records. It's sometimes convenient to have the records displayed for the operator when the form is presented. This is especially true for forms that will not contain a large amount of records. This can be accomplished by creating a When-new-form-instance trigger that contains the execute-query subprogram. |