how to code close infopath on submit

R

Rob Whittaker

I use InfoPath 2007 and I have seen many posts about the actual code needed
to close InfoPath after a form has been submitted but I am lost as to how to
actually know where the code should go step by step.

I want to close Infopath after submitting my form, i guess the following
code is correct
"XDocument.View.Window.Close(true)"

Where do I put this exactly? I right click on the submit button in my form,
select button properties and get the button properties dialog box. Under the
general tab with Action selected with "rules and custom code" , I click on
"Edit form code" (above "rules") and Microsoft Visual Studio Tools for
Applications open with a lot of pre written code.
See below

Imports Microsoft.Office.InfoPath
Imports System
Imports System.Windows.Forms
Imports System.Xml
Imports System.Xml.XPath
Imports mshtml


Namespace Template1
Public Class FormCode
' Member variables are not supported in browser-enabled forms.
' Instead, write and read these values from the FormState
' dictionary using code such as the following:
'
' Private Property _memberVariable() As Object
' Get
' _memberVariable = FormState("_memberVariable")
' End Get
' Set
' FormState("_memberVariable") = value
' End Set
' End Property

' NOTE: The following procedure is required by Microsoft Office
InfoPath.
' It can be modified using Microsoft Office InfoPath.
Private Sub InternalStartup(ByVal sender As Object, ByVal e As
EventArgs) Handles Me.Startup
AddHandler EventManager.XmlEvents("/my:myFields").Changing,
AddressOf myFields_Changing
AddHandler DirectCast(EventManager.ControlEvents("CTRL1_5"),
ButtonEvent).Clicked, AddressOf CTRL1_5_Clicked
End Sub

Public Sub myFields_Changing(ByVal sender As Object, ByVal e As
XmlChangingEventArgs)
' Ensure that the constraint you are enforcing is compatible
' with the default value you set for this XML node.
' Write your code here.
End Sub

Public Sub CTRL1_5_Clicked(ByVal sender As Object, ByVal e As
ClickedEventArgs)
' Write your code here.
End Sub
End Class
End Namespace

Where do I go from here I don't know??? Any help appreciated.
 
S

SMS

I use InfoPath 2007 and I have seen many posts about the actual code needed
to close InfoPath after a form has been submitted but I am lost as to howto
actually know where the code should go step by step.

I want to close Infopath after submitting my form, i guess the following
code is correct
"XDocument.View.Window.Close(true)"

 Where do I put this exactly? I right click on the submit button in my form,
select button properties and get the button properties dialog box. Under the
general tab with Action selected with "rules and custom code" , I click on
"Edit form code" (above "rules") and Microsoft Visual Studio Tools for
Applications open with a lot of pre written code.
See below

Imports Microsoft.Office.InfoPath
Imports System
Imports System.Windows.Forms
Imports System.Xml
Imports System.Xml.XPath
Imports mshtml

Namespace Template1
    Public Class FormCode
        ' Member variables are not supported in browser-enabled forms.
        ' Instead, write and read these values from the FormState
        ' dictionary using code such as the following:
        '
        ' Private Property _memberVariable() As Object
        '     Get
        '         _memberVariable = FormState("_memberVariable")
        '     End Get
        '     Set
        '         FormState("_memberVariable") = value
        '     End Set
        ' End Property

        ' NOTE: The following procedure is required by Microsoft Office
InfoPath.
        ' It can be modified using Microsoft Office InfoPath.
        Private Sub InternalStartup(ByVal sender As Object, ByVale As
EventArgs) Handles Me.Startup
            AddHandler EventManager.XmlEvents("/my:myFields")..Changing,
AddressOf myFields_Changing
            AddHandler DirectCast(EventManager.ControlEvents("CTRL1_5"),
ButtonEvent).Clicked, AddressOf CTRL1_5_Clicked
        End Sub

        Public Sub myFields_Changing(ByVal sender As Object, ByVal e As
XmlChangingEventArgs)
            ' Ensure that the constraint you are enforcing iscompatible
            ' with the default value you set for this XML node.
            ' Write your code here.
        End Sub

        Public Sub CTRL1_5_Clicked(ByVal sender As Object, ByVal e As
ClickedEventArgs)
            ' Write your code here.
        End Sub
    End Class
End Namespace

Where do I go from here I don't know??? Any help appreciated.

No need for code.

Goto Tools > Submit Options > Advanced

The last choice says "After Submit:" ...it is a dropdown. Choose,
"CLOSE THE FORM"
 
R

Rob Whittaker

This does not do I what I want. I already have this selected. I want the
instance of InfoPath to be closed after submit, not just the form. InfoPath
must close after the form hass been submitted. Please any ideas.
 
G

Guru

Hi ,

I got your concern as I had same issue.First let me clear you that
there is no such functionality to close infopath form via custom
button. To get this functionality:

1)Create separate view with Button OK

The form is submitted successfully

2)and in that view on click of ok, set rule to close form

3) On Submit Click, transit views
this.ViewInfos.SwitchView( ViewName);


I think this will meet your requirement
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top