Hello, I am a very bright green InfoPath user. What I would like is to be able to do two things at once when a user clicks a button.
1. Switch to a different view
2. Set focus to one of the controls on that view
I can get a button to switch views easily
Public Sub CTRL1_14_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)
ViewInfos.SwitchView(
"SF182")
End Sub
And after much frustration managed to get clicking a button to set focus on a control on the same view
Public Sub CTRL78_7_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)
Dim textNode As XPathNavigator = MainDataSource.CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:dataFields/d:tSF182/@EducLevel", NamespaceManager)
CurrentView.SelectText(textNode)
End Sub
Getting these two things to happen at the same time results in errors from the attempt
System.Runtime.InteropServices.COMException
The specified values for the View.SelectText call are not valid.
at Microsoft.Office.Interop.InfoPath.SemiTrust.View.SelectText(IXMLDOMNode pxnField, Object varViewContext)
at Microsoft.Office.Interop.InfoPath.SemiTrust.ViewObjectWrapper.SelectText(IXMLDOMNode pxnField, Object varViewContext)
at Microsoft.Office.InfoPath.Internal.ViewHost.SelectText(XPathNavigator xmlNode)
at ipfSF182a.FormCode.CTRL1_14_Clicked(Object sender, ClickedEventArgs e)
at Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)
at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)
Any ideas how I can make this work?