A field and a grid cell will automatically change its background color when a field or file error is encountered. A validation error can be generated through an OAM or through the BEGINCHECK set of RDML commands.
You will notice that when you are executing a form which has a command button, the error state is always cleared when the button is clicked in the same way as with error messages. This is built-in behavior for a push button.
Most other events have a value for the OPTIONS parameter set to *NOCLEARERRORS as the default. This option stops errors being cleared by the event routine. A few events do not have this parameter, most notably the click event of a button.
To make an event to clear errors, set the OPTIONS parameter of the EVTROUTINE command of the event to *CLEARERRORS.
Note that when a field or a grid cell loses focus, the error background color is automatically cleared. This is built-in behavior that cannot be changed. This behavior is based on the assumption that when focus is moved away from the field or the cell, the error has been corrected. If it has not, the error state will be activated again the next time an event which contains commands which use validation rules is triggered.
Showing Error States in Edit Boxes and Spin Edit Boxes
Edit boxes and spin edit boxes can be made to show error background color using the ShowError property. It should be remembered that it is always better practice to use fields and the repository-based validations than coding validation checking in the application.
Changing the Error Background Color
The default error background color is Fuchsia. This color can be changed in two ways: