Share via


Errors.Add Method

Adds an ErrorObject to ErrorsCollection and returns a reference to the new Error object.

Namespace: Microsoft.Office.Interop.InfoPath
Assembly: Microsoft.Office.Interop.InfoPath (in microsoft.office.interop.infopath.dll)

Syntax

'Declaration
'Usage

Parameters

  • varNode
    The XML node that the error will be associated with.
  • bstrConditionName
    The name of the error.
  • bstrShortErrorMessage
    The short message for the error.
  • bstrDetailedErrorMessage
    The detailed message for the error.
  • lErrorCode
    The error code of the error.
  • bstrType
    Default value is "modeless". The type of error processing. The other supported value is "modal".

Return Value

An ErrorObject object which represents the newly created 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

Note

Custom errors can also be created using the ReportError method.

Example

//Add an error to the node
IXMLDOMDocument myDOM = thisXDocument.DOM;
IXMLDOMNode myNode = myDOM.selectSingleNode("my:myFields/my:aGroup/my:field1");
thisXDocument.Errors.Add(myNode,"condition","short","detail",102057,"modeless");

See Also

Reference

Errors Interface
Errors Members
Microsoft.Office.Interop.InfoPath Namespace