So I got the Form to switch to my update view when the code begins. And at the end I check to see if I'm still on that form and attempt to switch back. I got a com error. I looked it up and it says I can't switch views multiple times within code supposedly. Which seems like a very odd limitation. Below is my code to switch back to my default view. And below that is my error message.
if (this.CurrentView.ViewInfo.Name == "Update")
{
//Switch back to original view
this.ViewInfos.SwitchView("Request"); //Causes an error because apparently you can't switch between views within code.... more than once
}
System.Runtime.InteropServices.COMException
InfoPath cannot execute any view-related object model calls. The view is not ready.
at Microsoft.Office.Interop.InfoPath.SemiTrust.View.SwitchView(String bstrName)
at Microsoft.Office.Interop.InfoPath.SemiTrust.ViewObjectWrapper.SwitchView(String bstrName)
at Microsoft.Office.InfoPath.Internal.ViewInfoCollectionHost.SwitchView(String name)
at QlikAcessRqst.FormCode.CTRL_Submit_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)