Question:
I want to be able to take an action when a user changes the value of a data field, but not when the value of the field is changed by code. How can I do this?
Answer:
The PostChange() method for a data field is called whenever the value of the field is changed by code or user interaction. The Validate() method is only called when a value is changed by a user.
When the Validate() method is called, the Value of the data field is the original value of the field. The new value for the field is in a variable called newval. You can compare the new value and the old value and in the Validate() method.
If you return TRUE from the Validate() method, normal processing continues. If you return FALSE from the method, the focus is left in the data field and subsequent actions are cancelled. You have to remember to explicitly return TRUE from the Validate() method; the default return is FALSE, which can cause unintended results.