Hello Folks,

I currently have a problem with trying to assign values using an XPathNavigator object in InfoPath. What I am trying to do is to perform a simple copy and nothing appears to be working. I don't know if I am doing something wrong or the syntax is incorrect. Could someone please take a look at the entry I have below and let me know what I am doing wrong or if there is a better way. I am in need of having multiple, select values on the form copied from one field to another once a button is clicked. I have the code below in a function called CopyEnteredValues that accepts an XPathNavigator object as a parameter. Any help would be greatly appreciated. I also posted the error message below:

"The following error occurred: Object reference not set to an instance of an object."

//I have posted a small code example below. There are several other copy statements other than the one below but I figured I would just show the one example.


void CopyEnteredValues(XPathNavigator xnDoc) 






//Get a reference to the form's XmlNamespaceManager object. 

XmlNamespaceManager ns = this.NamespaceManager; 

xnDoc.SelectSingleNode("my:DocTrackingAndTransmittalForm/my:secLast_Transaction/my:Current_Date", ns).SetValue(xnDoc.SelectSingleNode("my:DocTrackingAndTransmittalForm/secCurrent_Routing_Transmittal/my:Due_Date", ns).Value);



catch (Exception ex) 


MessageBox.Show("The following error occurred: " + ex.Message); 


5 Years
Discussion Span
Last Post by dhudnall

I was able to resolve the object reference error message by adding "my:" to the end of the second statement. The issue was related to syntax.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.