object.Errors.<member>...
This property keeps the reference to the object's errors collection. This collection is used to collect error messages generated during the object's execution.
Errors collection exposes three important members:
Member | Description |
---|---|
Errors.Count | This property returns the number of errors the collection contains. It can be used for testing if the collection is empty or contains any error messages. |
Errors.AddError <message> | This method adds specified error message to the collection. It can be used to insert error messages when performing custom validation. |
Errors.Clear | This method resets the collection removing all previously added error messages. It can be used to force successful form submit processing despite validation errors or to clear error messages before replacing them with custom ones. |
The following code checks if the errors collection is empty. If there are any error messages, all of them are replaced with a customized one.
The code assumes OrderForm form exists on the page. This code may be inserted into
On Validate event.
If OrderForm.Errors.Count > 0 Then OrderForm.Errors.Clear OrderForm.Errors.AddError "This order cannot be processed. Please fix it." End If
On Validate event