Hi Jimmy, I've tried to do what you've mentioned here as well as how you've guilded countless others through the same issue. I've probably read at least 10 different instances where you've helped others but I still can't get this to work for me. Here is the scenario:
Have two Filler Forms that are saved to a Form Library in SharePoint. One form is the master and the second is the details. On the master there is a repeating section (Master/Detail) that returns the detail records associated with the master. I've included a Button on the repeating table, inline with the data row. The idea is to have the button click open the detail record form. When I've hard coded the address of the detail form in the code the button has opened the detail record without issue.
In order to do what I want to do the button click needs to aquire values related to the row it belongs to and feed the variables to additonal code, this works fine but only returns the 1st row detail record regardless of which row button is pressed.
I've read countless articles, forum questions, blogs, and Microsoft articles but I still can't get this to work.
Below is the code I'm using, in it are the multiple lines of code that failed, they return the error "Object reference not set to an instance of an object" when I try to do what all the different articles say to do. Note that all I'm trying to do here is get one fields value to appear in a MessageBox, purely to prove that the button click is retrieving data from the correct row. Once i've established I've got that part working I have the rest of the code ready but didn't want to include it so as not to confuse the issues.
Public Sub CTRL152_5_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)
'
Dim nsp As XmlNamespaceManager = Me.NamespaceManager
Dim RowRec As XPathNavigator = e.Source.CreateNavigator()
'
'Dim mes As String = RowRec.OuterXml.ToString() *Returns values related to the correct row related to button clicked
'Dim mes As String = RowRec.SelectSingleNode("/dfs:myFields/dfs:dataFields/ns1:SharePointListItem_RW/ns1:Sec_x0020_Code_x0020_Num", NamespaceManager).Value.ToString() *Return 1st Row data*
'
'
'Dim mes As String = RowRec.SelectSingleNode("Sec_x0020_Code_x0020_Num", nsp).Value 'Error: Object reference not set to an instance of a object
'Dim mes As String = RowRec.SelectSingleNode("@Sec_x0020_Code_x0020_Num", nsp).Value 'Error: Object reference not set to an instance of a object
'Dim mes As String = RowRec.SelectSingleNode("../@Sec_x0020_Code_x0020_Num", nsp).Value 'Error: Object reference not set to an instance of a object
'Dim mes As String = RowRec.SelectSingleNode("../../@Sec_x0020_Code_x0020_Num", nsp).Value 'Error: Object reference not set to an instance of a object
'Dim mes As String = RowRec.SelectSingleNode("../../../@Sec_x0020_Code_x0020_Num", nsp).Value 'Error: Object reference not set to an instance of a object
'
MessageBox.Show(mes)
'
End Sub
The strange thing is that If I use the "OuterXml.ToString()" then the code does return the data related to the row that hold the button that was pressed. Here is what is returned in the MessageBox from the OuterXML:

If I use the full XPath to any field in the dataset, like: /dfs:myFields/dfs:dataFields/ns1:SharePointListItem_RW/ns1:Sec_x0020_Code_x0020_Num , then only the 1st row data is returned.
It seems like no matter how I construct the XPath for the field, if I include the "@" infront of the field name I get the error. And only if I give the full XPath without the "@" will I get anything, and in that case its the 1st row.