How tos
How To pass parameters between objects (forms, reports, ...)? Revisited
- Author
- Luc Van Dyck
- Date
- 04/02/2005
- Size
- 5,61 KB
- Downloads
-
3315
Detailed statistics
- Downloads today 1
- 30 day downloads 24
- Total downloads 3315
- Overall download rank #224 / 2084
- Today page views 0
- 30 days page views 7
- Total views 20159
- Rating


The on-line help describes this SingleInstance property as follows:
When you set this property to Yes on codeunit X, all codeunit variables that use codeunit X will use the same instance. That is, all codeunit variables of codeunit X will use the same set of internal variables when the code is running on the same client. Codeunit X remains instantiated until you close the company.
What this means is that the value of all variables that are used in a SingleInstance codeunit, remains in memory even after this codeunits exits. The 2nd time you use a
variable from the same codeunit, it will have the previous value instead of having the default value 0 or blank.
This example uses the same 2 forms as the previous How To:
- Form1 asks for a name and two decimal values
- After clicking the "Call Form2" button, these variables are passed to a SingleInstance codeunit.
Form2 retrieves the values from this codeunit, sends the result of the calculation back to the codeunit and displays the values.
- After clicking the "Return to Form1" button, focus is placed again on Form1. Form1 retrieves the result of the calculation from
the codeunit and displays the value.
This is the code behind the "Call Form2" button of Form1, which passes the values to the codeunit, and retrieves the result
of the calculation: