1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
<html dir="ltr"><head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<META HTTP-EQUIV="assetid" CONTENT="HV01021375"><META NAME="lcid" CONTENT="1033"><title>Add Method</title><link rel="stylesheet" type="text/css" href="office10.css"><script type="text/javascript" language="Javascript" src="ExpCollapse.js"></script><script type="text/javascript" language="JavaScript" src="inline.js"></script></head><body><p id="ExpandAllLine" class="ExpFav"><a href="#" onclick="ExpandAll()" onkeypress="ExpandAll()" class="DropDown"><img id="picHeader" border="0" src="expandtri.gif" alt="Show All"><span id="ExpandAll">Show All</span></a></p><h1>Add Method</h1><DIV class="ofvbanav"><span class="ofvbanavreuse" id="seealso" onclick="toggleList()" onkeypress="toggleList()"></span><span class="ofvbanavreuse" id="appliesto" onclick="toggleList()" onkeypress="toggleList()"></span><a class="ofvbanavex" href="#example"><span class="ofvbanavreuse" id="example"></span></a><span class="ofvbanavreuse" id="specifics" onclick="toggleList()" onkeypress="toggleList()"></span></DIV><p>
<p>Adds an <b class="bterm"><a href="xdobjError.htm" id="HV01021243" lcid=" ">Error</a></b> object to the <b class="bterm"><a href="xdcolErrors.htm" id="HV01021186" lcid=" ">Errors</a></b> collection and returns a reference to the new <b class="bterm">Error</b> object.</p>
<p class="signature"><i>expression</i>.<b class="bterm">Add</b>(ByVal <b class="bterm"><i>varNode</i></b> As Variant, ByVal <b class="bterm"><i>bstrConditionName</i></b> As String, ByVal <b class="bterm"><i>bstrShortErrorMessage</i></b> As String, [ByVal <b class="bterm"><i>bstrDetailedErrorMessage</i></b> As String], [ByVal <b class="bterm"><i>lErrorCode</i></b> As Long], [ByVal <b class="bterm"><i>bstrType</i></b> As String = "modeless"]) As Error</p>
<p><i>expression </i> Required. An expression that returns a reference to the <b class="bterm">Errors</b> collection.</p><p>
<b class="bterm">
<i>varNode</i>
</b>Required <b class="bterm">Variant</b>. The XML node that the error will be associated with.</p>
<p>
<b class="bterm">
<i>bstrConditionName</i>
</b>Required <b class="bterm">String</b>. The name of the error.</p>
<p>
<b class="bterm">
<i>bstrShortErrorMessage</i>
</b>Required <b class="bterm">String</b>. The short message for the error.</p>
<p>
<b class="bterm">
<i>bstrDetailedErrorMessage</i>
</b>Optional <b class="bterm">String</b>. The detailed message for the error.</p>
<p>
<b class="bterm">
<i>lErrorCode</i>
</b>Optional <b class="bterm">Long Integer</b>. Default value is 0. The error code of the error.</p>
<p><b class="bterm"><i>bstrType</i></b> Optional <b class="bterm">String</b>. Default value is "modeless". The type of error processing. The other supported value is "modal".</p><p><i>returns </i> A reference to the newly created <b class="bterm">Error</b> object.</p>
</p><h2>Security Level</h2><p>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.</p><h2>Remarks</h2><p>
<p>The <b class="bterm">Add</b> 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 <b class="bterm">Add</b> method:<ul><li><b class="runinhead">modeless</b> The user is notified of the error with an <a href="#" class="glossary" onclick="AppendPopup(this,'xdinlinealert')" onkeypress="AppendPopup(this,'xdinlinealert')">inline alert</a> and can choose to return to the previous value with an undo operation.</li><li><b class="runinhead">modal</b> The user is notified of the error with a <a href="#" class="glossary" onclick="AppendPopup(this,'xddialogboxalert')" onkeypress="AppendPopup(this,'xddialogboxalert')">dialog box alert</a>. After clicking <b class="ui">OK</b> 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.</li></ul><p><b>Note</b> Custom errors can also be created using the <b class="bterm"><a href="xdmthReportError.htm" id="HV01021405" lcid=" ">ReportError</a></b> method of the <b class="bterm"><a href="xdobjDataDOMEvent.htm" id="HV01021239" lcid=" ">DataDOMEvent</a></b> object.</p></p>
</p><h2><a id="#example" name="#example">Example</a></h2><p>
<p>In the following example, the <b class="bterm">Add</b> method of the <b class="bterm">Errors</b> collection is used to create a custom error message:</p>
<pre><code>var objErrors;
var objError;
objErrors = XDocument.Errors;
objError = objErrors.<b class="bterm">Add</b>(MyXMLNode, "ValidationError", "The data is invalid.");
</code></pre>
</p><script type="text/javascript" language="JScript" src="ofvbanl.js"></script><span id="ofVBAISpan" class="ofvbaispan"><iframe id="ofVBAIFrame" frameborder="0" marginheight="0" marginwidth="4" scrolling="auto" width="100%" src="../links/xdmthAdd_l.htm"></iframe></span><center><a href="XMLSchemaCopyright_HV01147162.htm">©2003-2004 Microsoft Corporation. All rights reserved.</a>
Permission to copy, display and distribute this document is available at: <a
href="http://r.office.microsoft.com/r/rlidAWSContentRedir?AssetID=XT010988631033&CTT=11&Origin=HV011232471033"
target="_new">http://msdn.microsoft.com/library/en-us/odcXMLRef/html/odcXMLRefLegalNotice.asp</a></center></body></html>
|