Adds an Error object to the Errors collection and returns a reference to the new Error object.
expression.Add(ByVal varNode As Variant, ByVal bstrConditionName As String, ByVal bstrShortErrorMessage As String, [ByVal bstrDetailedErrorMessage As String], [ByVal lErrorCode As Long], [ByVal bstrType As String = "modeless"]) As Error
expression Required. An expression that returns a reference to the Errors collection.
varNode Required Variant. The XML node that the error will be associated with.
bstrConditionName Required String. The name of the error.
bstrShortErrorMessage Required String. The short message for the error.
bstrDetailedErrorMessage Optional String. The detailed message for the error.
lErrorCode Optional Long Integer. Default value is 0. The error code of the error.
bstrType Optional String. Default value is "modeless". The type of error processing. The other supported value is "modal".
returns A reference to the newly created Error object.
2: Can be accessed only by forms running in the same domain as the currently open form, or by forms that have been granted cross-domain permissions.
The Add method is used to create custom error messages in a Microsoft Office InfoPath 2003 form. There are two types of errors that can be created using the Add method:
Note Custom errors can also be created using the ReportError method of the DataDOMEvent object.
In the following example, the Add method of the Errors collection is used to create a custom error message:
var objErrors;
var objError;
objErrors = XDocument.Errors;
objError = objErrors.Add(MyXMLNode, "ValidationError", "The data is invalid.");