This documentation is archived and is not being maintained.

Errors.Add Method

Office 2007
Adds an Error object to the Errors collection and returns a reference to the new Error object.

Version Information
 Version Added:  InfoPath 2003

Syntax

expression.Add(varNode, bstrConditionName, bstrShortErrorMessage, bstrDetailedErrorMessage, lErrorCode, bstrType)

expression   An expression that returns a Errors object.

Parameters

NameRequired/OptionalData TypeDescription
varNodeRequiredVariantThe XML node that the error will be associated with.
bstrConditionNameRequiredStringThe name of the error.
bstrShortErrorMessageRequiredStringThe short message for the error.
bstrDetailedErrorMessageOptionalStringThe detailed message for the error.
lErrorCodeOptionalLongDefault value is 0. The error code of the error.
bstrTypeOptionalStringDefault value is modeless. The type of error processing. The other supported value is modal.

Return Value
Error

Remarks

The Add method is used to create custom error messages in a Microsoft Office InfoPath 2007 form. There are two types of errors that can be created using the Add method:

  • modeless: The user is notified of the error with an inline alert and can choose to return to the previous value with an undo operation.
  • modal: The user is notified of the error with a dialog box alert. After clicking OK in the dialog box alert, the error will appear as an inline alert and the user can choose to return to the previous value with an undo operation.
Bb229747.vs_note(en-us,office.12).gif  Note
Custom errors can also be created using the ReportError method of the DataDOMEvent object.

Security Level 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.

Example

In the following example, the Add method of the Errors collection is used to create a custom error message:

JScript
var objErrors;
var objError;

objErrors = XDocument.Errors;
objError = objErrors.Add(MyXMLNode, "ValidationError", "The data is invalid.");



Show: