The need to use both WHEN-VALIDATE-RECORD and WHEN-VALIDATE-ITEM is quite often felt in coding applications where independent validations are to be done, at the record and item levels. As a special case of this, validation between interdependent items is best done using a WHEN-VALIDATE-RECORD trigger.
You should use a WHEN-VALIDATE-RECORD trigger to perform validation when control moves out of the whole record and not when it just moves out of an item in the record.
Use a WHEN-VALIDATE-ITEM trigger to perform validation when control moves out of an item. This also implies that the control might move out of the record in the process. But the subtle difference is WHEN-VALIDATE-RECORD fires only when the control exits the whole record. It does not fire while tabbing between items in the same record.
How Does the Validation Unit Property Influence This Behavior?
Setting the Validation Unit property to Record defers the validation process until the control navigates out of the record. This is similar to the behavior of a WHEN-VALIDATE-RECORD trigger except that it also postpones the firing of the WHEN-VALIDATE-ITEM trigger until this point. At this time, WHEN-VALIDATE-ITEM fires followed by WHEN-VALIDATE-RECORD.
Examples of situations requiring a WHEN-VALIDATE-RECORD are
Imagine the complexity when there are more than three items. A WHEN-VALIDATE-RECORD trigger, on the other hand, would require only one combined validation involving all three items.
Writing individual WHEN-VALIDATE-ITEM triggers for each of the interdependent items requires the code performing the combined validation to be repeated in each trigger. This increases the complexity of coding when a lot of these items are involved. Also the probability of error is greater in this case.
On the other hand, writing a WHEN-VALIDATE-RECORD trigger requires only doing the combined validation once, and this method is completely error-proof.
GUI Development
Advanced GUI Development: Developing Beyond GUI
Multi-form Applications
Advanced Forms Programming
Error-Message Handling
Object-oriented Methods in Forms
Intelligence in Forms
Additional Interesting Techniques
Working with Trees
Oracle 8 and 8i Features in Forms Developer