Greg
I am trying to implement your '
Highlight the Active Field' code in VB managed code. However, I think I have hit a wall in that my fields are actually 'Attributes' (created as such probably from the datasource connection to a SQL table).
Here's the code and the associated error:
Code:
----------------------------
<InfoPathEventHandler(EventType:=InfoPathEventType.OnContextChange)> _
Public Sub OnContextChange(ByVal e As DocContextChangeEvent)
If (e.Type <> "ContextNode") Or e.IsUndoRedo Then
' XML Selection or Context has changed. Write code here to respond to the changes.
Return
End If
Dim strNode As String = e.Context.nodeName
strNode = "/dfs:myFields/dfs:dataFields/d:TSRTrack/@" + strNode
Dim nodCurrent As IXMLDOMNode = e.XDocument.DOM.selectSingleNode(strNode)
Try
e.XDocument.SetNamedNodeProperty(nodCurrent, "active", "0")
Catch ex As Exception
End Try
e.XDocument.SetNamedNodeProperty(nodCurrent, "active", "1")
End Sub
---------------------------
Error:
System.Runtime.InteropServices.COMException was unhandled by user code
ErrorCode=-2147209216
Message="An invalid parameter was specified for the SetNamedNodeProperty method.
#65279;#65279;
The first parameter must be a non-attribute node of the main data source."
Source="InfoPath"
StackTrace:
at Microsoft.Office.Interop.InfoPath.SemiTrust._XDocument2.SetNamedNodeProperty(IXMLDOMNode pxmlMainDOMNode, String bstrPropertyName, String bstrValue)
at Microsoft.Office.Interop.InfoPath.SemiTrust.XDocumentWrapper.SetNamedNodeProperty(IXMLDOMNode pxmlMainDOMNode, String bstrPropertyName, String bstrValue)
at TechServiceRequest.TechServiceRequest.OnContextChange(DocContextChangeEvent e) in C:\Documents and Settings\young_m\My Documents\SCP InfoPath Forms\TechServiceRequest\TechServiceRequest\FormCode.vb:line 126
at Microsoft.Office.Interop.InfoPath.SemiTrust._XDocumentEventSink2_SinkHelper.OnContextChange(DocContextChangeEvent pEvent)
-----------------------------
Am I hosed?
TIA,