Are you trying to recreate the form from the tutorial? If you followed the steps exactly, the code should work (I still have my XSN that I made for that HowTo if you want it). Or are you trying to apply the HowTo to your own situation?
Either way, it sounds like you are getting an XPath error so that selectSingleNode returns a null object. As a quick test update your code for the following and tell me where the error occurs:
// The following function handler is created by Microsoft Office InfoPath.
// Do not modify the name of the function, or the name and number of arguments.
//=======
function btnViewDetail::OnClick(eventObj)
{
var oQueryId = XDocument.DOM.selectSingleNode
("/dfs:myFields/dfs:queryFields/q:Customers/@CustomerID" );
XDocument.UI.Alert( oQueryId.text );
XDocument.UI.Alert( eventObj.Source.selectSingleNode("@CustomerID").text );
oQueryId.text = eventObj.Source.selectSingleNode("@CustomerID").text;
XDocument.Query();
XDocument.View.SwitchView("Detail");
}
Matt Faus / Microsoft InfoPath MVPQdabra® Software / Streamline data gathering to turn process into knowledge