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.
public
void CopyEnteredValues(XPathNavigator xnDoc)
{
try
{
//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);
throw;
}
}