Show All

# NewValue Property

A read-only property that returns a string value indicating the value of an XML Document Object Model (DOM) node that is being updated or inserted during a data validation event.

expression.NewValue

expression Required. Returns a reference to 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.

## Remarks

The NewValue property contains the value of the XML DOM node that will replace the existing value. To get the original value of the XML DOM node, use the OldValue property of the DataDOMEvent object.

## Example

In the following example from the ADO (ActiveX Data Objects) developer sample form, the NewValue property of the DataDOMEvent object is used to determine whether the new value of the XML DOM node is an empty string. If it is not, the code sets other fields to be empty strings.

    function msoxd__Employees_EmployeeID_attr::OnAfterChange(eventObj)
    {
       if (eventObj.IsUndoRedo)
       {
          // An undo or redo operation has occurred and the DOM is read-only.
          return;
       }

       if (eventObj.NewValue == "")
          return;

       if (XDocument.DOM.selectSingleNode
          ('/dfs:myFields/dfs:queryFields/q:Employees/@FirstName').text != "")
          XDocument.DOM.selectSingleNode
             ('/dfs:myFields/dfs:queryFields/q:Employees/@FirstName').text = "";

       if (XDocument.DOM.selectSingleNode
          ('/dfs:myFields/dfs:queryFields/q:Employees/@LastName').text != "")
          XDocument.DOM.selectSingleNode
             ('/dfs:myFields/dfs:queryFields/q:Employees/@LastName').text = "";
    }

©2003-2004 Microsoft Corporation. All rights reserved. Permission to copy, display and distribute this document is available at: http://msdn.microsoft.com/library/en-us/odcXMLRef/html/odcXMLRefLegalNotice.asp