How To pass parameters between objects (forms, reports, ...)?Author: Luc Van Dyck
This example uses 2 forms:
- Form1 asks for a name and two decimal values
- After clicking the "Call Form2" button, these variables are passed to
Form2, where they are displayed.
- After clicking the "Return to Form1" button, focus is placed again on
Form1 and the result of the calculation (decimal1 + decimal2) is displayed.
This is the code behind the "Call Form2" button of Form1. Form2 is defined as a
variable (frmForm2), otherwise it isn't possible to call the functions on that form.
decResult := 0;
IF frmForm2.RUNMODAL = ACTION::Close THEN BEGIN
decResult := frmForm2.fctGetResult;
Here are the functions of Form2, which accepts the parameters and returns the result of the calculation. The
parameters are stored in global variables, so they can be used in the form.