getForm

getForm(formName: String): Form;

The getForm method of the Application class enables logic to access the active forms in the application by name and returns a reference to the first active form object with the name specified in the formName parameter or null if there is no active form with the specified name.

This method returns an object of type Form, which is the superclass of all forms, enabling you to access all standard form properties.

To access the properties and methods specific to a particular form subclass, you must convert the returned object to a form object of the correct form type (by using a type guard operation).

The following example shows the use of the getForm method to retrieve the current period number from the first MaintPeriods form.

vars
    form          : Form;
    currentPeriod : Integer;
begin
    form := app.getForm("MaintPeriods");
    if form <> null then
        currentPeriod := form.MaintPeriods.currentPeriod;
    else
        currentPeriod := 0;
    endif;
    return currentPeriod;
end;