infopath save method
infopath save method
infopath save method
infopath save method
infopath save method
infopath save method infopath save method infopath save method infopath save method infopath save method infopath save method infopath save method infopath save method
infopath save method infopath save method
infopath save method
Go Back  Xtreme Visual Basic Talk > > > infopath save method


Reply
 
Thread Tools Display Modes
  #1  
Old 07-29-2011, 02:11 PM
gr8fasushi gr8fasushi is offline
Newcomer
 
Join Date: Jan 2011
Posts: 5
Default infopath save method


hi guys,

I'm trying to create a save button on my infopath form that when clicked, it automatically saves the infopath form to a directory. I'm running into some issues, I thought it would be simple but is quickly becoming confusing. Here is my current code:

Code:
Me.SetSaveAsDialogLocation("C:\Documents and Settings\18501\Desktop\")
Me.SetSaveAsDialogFilename("test.xsn")
Me.save
I've tried searching all over but couldn't find an answer that pertained to xml documents such as an infopath form. any help is greatly appreciated!
Reply With Quote
  #2  
Old 07-30-2011, 08:55 AM
passel's Avatar
passelinfopath save method passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,028
Default

I'm not familiar with infopath forms, but I guess my question is do you have code in the save event handler?
I believe that Me.Save will just cause the event to happen, but you probably need some code in the event handler to actually save the information.
The example in MSDN shows the code ensuring that a specific field is not empty, and if it is not, then saves the form, using e.PerformSaveOperation
Code:
Public Sub FormEvents_Save(ByVal sender As Object, _
   ByVal e As SaveEventArgs)
   ' Check to see if Field2 is empty.
   Dim reqField as XPathNavigator = 
      CreateNavigator().SelectSingleNode("/my:myFields/my:field2", _
      NamespaceManager)
   If(reqField.ToString() = "") Then
      MessageBox.Show("Field2 is empty" & vbNewLine & _
         "You cannot save the form.")
      e.CancelableArgs.Cancel = True
   Else
   ' The Dirty property will be set to false if save is successful.
   e.PerformSaveOperation()
   e.CancelableArgs.Cancel = False
   End If
End Sub
Also, since Infopath forms are associated with Microsoft Office, I'll move the thread to .Net Office Automation. But, I can see that it may not be considered Automation either, but long time users of Office may be more familiar with the specifics of the Infopath libraries.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.

Last edited by passel; 07-30-2011 at 09:05 AM.
Reply With Quote
  #3  
Old 07-31-2011, 02:03 PM
gr8fasushi gr8fasushi is offline
Newcomer
 
Join Date: Jan 2011
Posts: 5
Default

thank you very much! yes I have enabled the event handler in the options to perform custom code when save is triggered. I actually did use the code above and it works when I click the save button. Now, how would you call the FormEvents_Save subroutine through code? the idea is that when someone clicks a button on the bottom of the form, it will perform several tasks, and one of them is to perform a save to a specified folder.

I've tried just using FormEvents_Save() but it isn't accepting it, probably because I haven't specified anything for the overloaded values (ByVal sender As Object, ByVal e As SaveEventArgs). I'm not sure what to input for this data. Also, I've tried adding Handles btnSubmit.Click but that doesn't work either.

any additional suggestions are greatly appreciated!
Reply With Quote
  #4  
Old 08-01-2011, 02:49 PM
passel's Avatar
passelinfopath save method passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,028
Default

I don't know anything about infopath, but if the save button works, then the code in the save button would be the code you would use, I would think.

i.e. if you called Me.Save in your code, then FormEvents_Save subroutine would be called to handle the event.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #5  
Old 08-03-2011, 03:54 PM
gr8fasushi gr8fasushi is offline
Newcomer
 
Join Date: Jan 2011
Posts: 5
Default

I tried that as well. However, it brings back an error "The form does not have a file name" even though there is one specified. Here's my current code:

Code:
        Public Sub FormEvents_Save(ByVal sender As Object, ByVal e As SaveEventArgs)
            ' Write your code that will run before a Save or Save As operation here.
            Me.SetSaveAsDialogLocation("\\labshare\shared\IT UUHC\Data\test")
            Me.SetSaveAsDialogFilename("abc123.xsn")


            ' The Dirty property will be set to false if save is successful.
            e.CancelableArgs.Cancel = False
            e.PerformSaveOperation()

            ' Write your code that will run after saving here.

            'e.CancelableArgs.Cancel = False
        End Sub



        Public Sub CTRL12_5_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)

            Me.Save()
        End Sub
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
infopath save method
infopath save method
infopath save method infopath save method
infopath save method
infopath save method
infopath save method infopath save method infopath save method infopath save method infopath save method infopath save method infopath save method
infopath save method
infopath save method
 
infopath save method
infopath save method
 
-->