Printable Version
 Updates

 Documentation

 Support & Training

 Community
  Online Forum
  Newsgroups
Using Actions to Set and Retrieve Control Values

Products:   
Areas: ASP, Perl 

Setting and Retrieving Control Values:

Sometimes it is necessary to set or get the value of a control within an event such as the Before Show event of the field or one of the events that occur after a record form is submitted. For instance, if you have a Label control in a grid and want to alter the appearance of its corresponding database value before it is displayed, you can use the Retrieve Value for Control action within the Before Show event of the Label field:

When you add a Retrieve Value for Control action, you are required to specify three properties:

Control Name:  The name of the control whose value is to be set
Source Type: The method to be used to set the control value
Source Name: The variable or expression that contains the new value

In this example, we want to add some text to the database value. As such, the Source Type property is set to Expression. For the Source Name, we enter an expression containing the text to be appended i.e. for ASP the Source Name property is set to:

“Database Value is: ” & FormName.FieldName.Value                                                                      

and for PHP the Source Name property is set to:

“Database Value is: ” . $FormName->FieldName->GetValue();

In the above code, FormName and FieldName should be replaced with the names of the form and field respectively.

The Retrieve Value for Control action has a partner action called the Save Control Value which can be used to extract the current value of a control. When you add a Save Control Value action to an event such as the Before Show event of the field or one of the events that occur after a record form is submitted, you are required to specify the same three properties as was done with the Retrieve Value for Control action. So for instance if we want to save the value of a control into a variable called myVar, you would set the Source Type property to Variable and the Source Name to myVar. The code generated for the action would be:

‘ASP
myVar = FormName.FieldName.Value

‘PHP
global $FormName;
global $myVar;
$myVar = $FormName->FieldName->GetValue();

Where FormName and FieldName are the names of the form and field respectively.



Viewed 20484 times.   Last updated: 11/8/2002 11:29:12 PM