Add Method
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

Errors.Add Method (Microsoft.Office.Interop.InfoPath)

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)

ErrorObject Add (
	[InAttribute] Object varNode,
	[InAttribute] string bstrConditionName,
	[InAttribute] string bstrShortErrorMessage,
	[OptionalAttribute] [InAttribute] string bstrDetailedErrorMessage,
	[OptionalAttribute] [InAttribute] int lErrorCode,
	[OptionalAttribute] [InAttribute] string bstrType
)

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.

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

NoteNote:

Custom errors can also be created using the ReportError method.

//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");
Show:
© 2016 Microsoft