Passing Parameters to a Form
Sometimes you want to pass parameters to forms when you run them to set property values or specify operational defaults.
To pass a parameter to a form created in the Form Designer
Create properties on the form to hold the parameters, such as ItemName and ItemQuantity.
In the Init event code for the form, include a PARAMETERS statement such as:
PARAMETERS cString, nNumber
In the Init event code for the form, assign the parameters to the properties, as in this example:
THIS.ItemName = cString THIS.ItemQuantity = nNumber
When running the form, include a WITH clause in the DO FORM command:
DO FORM myform WITH "Bagel", 24
Returning a Value From a Form
You can use forms throughout your application to allow users to specify a value.
To return a value from a form
Set the WindowType property of the form to 1 to make the form modal.
In the code associated with the Unload event of the form, include a RETURN command with the return value.
In the program or method that runs the form, include the TO keyword in the DO FORM command.
For example, if
FindCustID
is a modal form that returns a character value, the following line of code stores the return value to a variable namedcCustID
:DO FORM FindCustID TO cCustID
For more information, see RETURN and DO FORM.
Note If you get an error, make sure the WindowType is set to 1 (Modal).
See Also
Hiding a Form | Saving a Form as HTML | Creating Forms | Managing Multiple Instances of a Form | Setting the Design Area for a Form