ComponentOne True DataControl 8.0
Using Error Event in Field Validation

You can override the standard True DataControl error handling by providing your Error event procedure. Setting the fCancelDisplay argument to True in the Error event procedure cancels the standard message box. You can provide whatever error handling you need, including error messages and other user interaction. If you want to restore the previous field value, you can do it in the Error event calling the CancelUpdate method.

To distinguish the situation where Error event is triggered by a field validation failure, use the Source and ErrorNumber arguments. This is necessary because the Error event occurs not only on validation failures, but also on other errors, such as saving data in the database.

On a field modification failure, the Source argument is set to “TData”, and the ErrorNumber is one of the following:

2000

Field constraint violation.

2002

Required field is left empty.

2003

Data type conversion error: data entered by the user in a bound control is invalid with respect to the field’s data type.

2005

Field is read-only. And attempt has been made to change the value of a read-only field.

2006

Data type conversion error: the new value assigned to a field programmatically is invalid with respect to the field’s data type.

For all these errors, the FieldName argument of the Error event is set to the name of the field where the failure occurred.

 

 


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

Product Support Forum  |  Documentation Feedback