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
Function Add ( _
    varNode As Object, _
    bstrConditionName As String, _
    bstrShortErrorMessage As String, _
    bstrDetailedErrorMessage As String, _
    lErrorCode As Integer, _
    bstrType As String _
) As ErrorObject
'Usage
Dim instance As Errors
Dim varNode As Object
Dim bstrConditionName As String
Dim bstrShortErrorMessage As String
Dim bstrDetailedErrorMessage As String
Dim lErrorCode As Integer
Dim bstrType As String
Dim returnValue As ErrorObject

returnValue = instance.Add(varNode, bstrConditionName, _
    bstrShortErrorMessage, bstrDetailedErrorMessage, _
    lErrorCode, bstrType)
ErrorObject Add(
    Object varNode,
    string bstrConditionName,
    string bstrShortErrorMessage,
    string bstrDetailedErrorMessage,
    int lErrorCode,
    string bstrType
)

Parameters

  • varNode
    Type: System.Object

    The XML node that the error will be associated with.

  • bstrShortErrorMessage
    Type: System.String

    The short message for the error.

  • bstrDetailedErrorMessage
    Type: System.String

    The detailed message for the error.

  • lErrorCode
    Type: System.Int32

    The error code of the error.

  • bstrType
    Type: System.String

    Default value is "modeless". The type of error processing. The other supported value is "modal".

Return value

Type: Microsoft.Office.Interop.InfoPath.ErrorObject
An ErrorObject object which represents the newly created Error.

Remarks

The Add method is used to create custom error messages in a Microsoft InfoPath 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.

Examples

//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