programmatically changing the view of a form from a different form - InfoPath Dev
in

InfoPath Dev

programmatically changing the view of a form from a different form

Last post 01-17-2012 03:00 PM by gr8fasushi. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 01-17-2012 09:37 AM

    programmatically changing the view of a form from a different form

     Hi guys,

     

    I've tried searching the forums but I couldn't find anything related to what I need.

     

    For specific reasons, I need to change the view of a form from code.  Specifically, I want to open a different form with a specific view from another form.  I have the code running to open a different form through code:

    Dim Proc As New System.Diagnostics.Process
    Dim path As String = "{path directory}"
    Proc.StartInfo.WorkingDirectory = path
    Proc.StartInfo.FileName = "eQI form.xsn"
    Proc.Start()

     

    this opens the form, I just need to change the view on that open form and I'm having a pickle of a time finding a solution.  I can find code to change the view for the current form, but not for changing the view of a different form that's also open.

     

    Do you guys know of the coding syntax to do so?  Thanks for your help in advance!

  • 01-17-2012 02:01 PM In reply to

    Re: programmatically changing the view of a form from a different form

    You'll need to pass in some input parameters into your other form.  Your other form will then read the parameter and open the correct view based on what that value is.  There is a blog post that describes this in more detail:

    http://blogs.msdn.com/b/infopath/archive/2007/02/26/passing-data-into-a-form-input-parameters.aspx

    Alternatively, qRules lets you do this easily with the GetInputParameter and SetDefaultView.  More info on qRules: http://www.qdabra.com/en/products/qRules_overview.aspx

    Anson Hidajat
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™

  • 01-17-2012 03:00 PM In reply to

    Re: programmatically changing the view of a form from a different form

    thank you!

     

    this pointed me in the general direction.  I ended up passing a value into a ghost text box on the 2nd form, and on load, based on that value, it opened up the view I needed.  Thanks for your help.  Here was my solution for others with the same problem - I'm using VB.NET

    dim path as string = "insert path"

    dim newForm as XmlForm = Application.XmlForms.NewFromFormTemplate(path)

    dim nav as XPathNavigator = newForm.MainDataSource.CreateNavigator().SelectSingleNode("insert xpath", newForm.NameSpaceManager)

    nav.SetValue(1)

     

    on the 2nd form on the Load event, it checks the value of the text box, if it's 1, then change views.

Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.