Visual Basic code needed to Save current form in InfoPath

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!

Doug
dougshepardAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Clay FoxDirector of Business IntegrationCommented:
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
0
dougshepardAuthor Commented:
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!

Doug
0
Clay FoxDirector of Business IntegrationCommented:
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.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dougshepardAuthor Commented:
Ahh... I had to check the "Allow overwrite if file exists" checkbox for the Data Connection being used for the Submit.  Nice... thanks!

Doug
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.