ComponentOne True DataControl 8.0
Standard Error Message in Field Validation

If not overridden by the Error event handler code, the standard True DataControl reaction to a field error is to display a message box with the field name and error description:

This does not include errors detected in the WillChangeField event. You must provide your own error handling if you cancel an update in the WillChangeField event, as True DataControl will not display its standard error message box or fire the Error event in this case.

The message box caption can be changed (most probably, to your application name) by setting the ErrorMsgCaption property.

The prompt to restore the previous value appears only if the field’s ModificationMode is 2 – Leaving control. For ModificationMode = 1 – Immediate, True DataControl always restores the previous value when the message box is closed, without prompting the user. The Lite version, True DataControl Lite also behaves this way, it does not prompt the user for restoring the previous value.

The prompt to restore the previous value can be removed from the message box by setting the ErrorMsgRestore property to False. It can be set to False permanently, or the setting can be changed in the Error event, just before the message box appears. Also, the prompt text can be customized calling the SetUIString method.

When the message box closes, True DataControl returns focus to the bound control where the error occurred. If the user answered Yes to the prompt, True DataControl restores the previous value in the control so the user can move focus out of the control without leaving incorrect value there.

If you do not like the standard restore prompt, you can set ErrorMsgRestore property to False, so the prompt will not appear, and provide your own means of reverting changes. For example, you can rely on the TData control’s Cancel button (set the ButtonCancel property to True), or you might provide a Cancel or Undo command button calling the CancelUpdate method. If you use a command button, make sure to set the button’s CausesValidation property to False, to make the button accessible in case of error. You must use the TData control's CancelUpdate method instead of the standard TData.Recordset.CancelUpdate, because the standard ADO CancelUpdate will do nothing until a field’s value is changed, and it won’t be changed in case of an error, a kind of vicious circle.

Some bound controls will restore the previous value regardless of the user’s answer to the restore prompt. For example, Microsoft DataGrid control behaves this way. This is because it always restores previous value if an error occurs. Some users can consider this behavior rude, it does not allow them to fix an incorrect value, the invalid value is instantly obliterated. True Data cannot override this behavior. If this bothers you, we can only suggest you use a different bound control, one that does not restore previous values on every error. ComponentOne True DBGrid, for example, behaves correctly.

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback