version 3
Modified (field) Boolean
| Parameter | Type | Description | |
| field | Field | Field to test | |
| Function result | Boolean | True if the field has been assigned a new value, | |
| otherwise False |
Description
Modified returns True if field has been programmatically assigned a value or has been edited during data entry. The command Modified must be used in a form method (or a subroutine called by a form method) only.
During data entry, a field is considered modified if the user has edited the field (whether or not the original value is changed) and then left it by going to another field or by clicking on a control. Note that just tabbing out of a field does not set Modified to True. The field must have been edited in order for Modified to be True.
When executing a method, a field is considered to be modified if it has been assigned a value (different or not).
Note: Modified always returns True after the execution of the commands PUSH RECORD and POP RECORD.
In any cases, use the Old command to detect if the field value has been actually changed.
Note: Although modified can be applied to any type of field, if you use it in combination with the old command, be aware of the restrictions that apply to the old command. For details, see the description of the Old command.
During data entry, it is usually easier to perform operations in object methods than to use Modified in form methods. Since an object method is sent an On Data Change event whenever a field is modified, the use of an object method is equivalent to using Modified in a form method.
Note: To operate properly, the Modified command is to be used only in a form method or in a method called by a form method.
Examples
1. The following example tests if either the [Orders]Quantity field or the [Orders]Price field has changed. If either has been changed, then the [Orders]Total field is recalculated.
If ((Modified ([Orders]Quantity) | (Modified ([Orders]Price)) [Orders]Total :=[Orders]Quantity*[Orders]Price End if
Note that the same thing could be accomplished by using the second line as a subroutine called by the object methods for the [Orders]Quantity field and the [Orders]Price field.
2. You select a record for the table [anyTable], then you call multiple subroutines that may modify the field [anyTable]Important field, but do not save the record. At the end of the main method, you can use the Modified command to detect if you must save the record:
` Here the record has been selected as current record ` Then you perform actions using subroutines DO SOMETHING DO SOMETHING ELSE DO NOT FORGET TO DO THAT ` ... ` At then you test the field to detect if the record has to be saved If (Modified([anyTable]Important field)) SAVE RECORD([anyTable]) End if
See Also
Old.