I have an InfoPath form with multiple views that I open inside a SharePoint library. The default view has a Submit button, and when clicked, it runs the following code:
' Some code to set values
Me.DataConnections(connectionName).Execute().
Application.Quit(True)
This works fine the first time. I'm able to submit the form with a unique name in a SharePoint library, and this triggers a workflow in SharePoint.
This form is again opened from SharePoint library list, but the next time, it's a different view with an Approve button. The approve button has the same code as above, but when executed, I get the following error:
InfoPath cannot submit the form.
An error occurred while the form was being submitted.
A value in the form may be used to specify the file name. If you know the value in the form that specifies the file name, revise it and try again. Otherwise, contact the author of the form template.
at Microsoft.Office.InfoPath.Internal.MomExceptionHelper.ExecuteDataConnectionAction(OMCall d)
at Microsoft.Office.InfoPath.Internal.FileSubmitConnectionHost.Execute()
at TestForm.FormCode.ApproveButton_Clicked(Object sender, ClickedEventArgs e) in FormCode.vb:line 168
at Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)
at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)
Line 168 is the code Me.DataConnections(connectionName).Execute()
My understanding is that when this line is executed, it doesn't know what form to reference. Correct?
My question how do I fix this?
I'm googling for solutions, but if someone already knows a solution, it will save me a great deal of time.
BTW, I don't want to use the Rules in the button properties. I'm already using that approach, for what I want to do, it's not good approach.