Event handler procedures in form modules

In addition to variable declarations and the main program, a form module can contain procedures that are handlers of the events related to the form. The events of opening and closing the form window are the most common events that can be handled in the form module (listing 5.18).

Listing 5.18. Form module

Procedure OnCreateAtServer(Cancel, StandardProcessing)
    // Insert handler content

Procedure OnOpen(Cancel)
    // Insert handler content

It is important that the names of these procedures are not fixed, you can name them as you like. And it is not sufficient, for example, to define the OnCreateAtServer or OnOpen procedures in the module. You also have to link them to the respective form events in Designer (fig. 5.17).


Fig. 5.17. Form events

Novice developers often forget about this aspect. To avoid such situations, we recommend that you use the opening buttons  in the property palette to generate the procedures (fig. 5.18).

Fig. 5.18. Form events

Alternatively, you can select them from the drop-down list that is available when you are in the form module (fig. 5.19).

Fig. 5.19. List of form events

In this case, the procedure definitions are automatically generated and linked to the respective form properties.

Next page: Understanding form module content

Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.