[Webinar] Streamline your web hosting managementRegister Today


Visual Basic code needed to Save current form in InfoPath

Posted on 2008-02-03
Medium Priority
Last Modified: 2013-11-26
I am new to Visual Basic.  I am designing a form in InfoPath 2007.  I have it setup so a button has to be clicked to "approve" the form (which does a bunch of stuff, including closing the form).  Right now I have a message that says "be sure to click Yes when prompted to Save" but I would like to avoid having my users mess this up.  I would like to use code to Save and Close the form (code runs after rules from what I have read, so this should work perfectly).  I will make the final rule action set a field to the value of "SAVE-AND-CLOSE".  I then want the code to run and if it finds the value "SAVE-AND-CLOSE" in the field, it will save (without prompts, the form has already been submitted to SharePoint and opened again from SharePoint at this point) and close.

Can anyone tell me what the code should look like to do this?

Thanks much!

Question by:dougshepard
  • 2
  • 2
LVL 28

Expert Comment

by:Clay Fox
ID: 20814482
So you are saving a local copy in addition to submitting to SharePoint?
Typically you would create another submit (which saves the form to a file location) rather then using the save or save as. That way it happens automatically and there is no user dependency. You can turn off the Save prompt for the user in Form options.

For VB coding examples, I would look at http://www.infopathdev.com

Author Comment

ID: 20814779
No, I am not saving a local copy.  I just want to save it via code (to it's current location which is a SharePoint document library) before closing it to avoid the Yes/No/Cancel prompt (where my user could mistakenly hit No).

I will check out the link you provided.  Thanks!

LVL 28

Accepted Solution

Clay Fox earned 2000 total points
ID: 20815066
If that is the case, just trigger your Submit to SharePoint Data connection again either via a rule on the button or via code. This saves the document to Sharepoint.

Turn off the ability for users to save in form options. That way they are not confused with it each time and it is only relevant if you want them savign themselves.

Author Comment

ID: 20815516
Ahh... I had to check the "Allow overwrite if file exists" checkbox for the Data Connection being used for the Submit.  Nice... thanks!


Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
How to fix display issue, screen flickering issue when I plug in power cord to the machine. Before I start explaining the solution lets check out once the issue how it looks like after I connect the power cord. most of you also have faced this…
Suggested Courses

590 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question