How to call a form from another one - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

How to call a form from another one

Last post 07-25-2006 12:39 AM by Raoul. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 07-20-2006 01:29 PM

    • Raoul
    • Top 500 Contributor
    • Joined on 05-05-2006
    • Posts 32

    How to call a form from another one

    Hi all,
    I need to call a form from another form.
    For example:
    in alfa.xsn form I need a button that start bravo.xsn and also close alfa.xsn . I need this code in vbscript (if possible).
    Thanks in advance.
    Raoul
  • 07-20-2006 02:05 PM In reply to

    Re: How to call a form from another one

    Look into the NewFromSolution and NewFromSolutionWithData methods.
  • 07-20-2006 04:04 PM In reply to

    • Raoul
    • Top 500 Contributor
    • Joined on 05-05-2006
    • Posts 32

    Re: How to call a form from another one

    Hi Greg,
    thank you for your answer. I have just tryed with NewFromSolution method and it work fine, but I have a problem to pass a string field from alfa.xsn to bravo.xsn. Have you some ideas?
    Many thanks. Raoul
  • 07-20-2006 04:28 PM In reply to

    Re: How to call a form from another one

    When you call NewFromSolution() it returns you an XDocument object to the form just opened. Use this returned object to select the field in the newly opened form you want to update (just like you normally do in your code) and then set the value.
  • 07-21-2006 06:01 AM In reply to

    • Raoul
    • Top 500 Contributor
    • Joined on 05-05-2006
    • Posts 32

    Re: How to call a form from another one

    Hi Greg,
    thanks for your reply. I have tryed this steps:

    1 - Application.XDocuments.NewFromSolution("urn:bravo:Myname")
    2 - Set objNewDoc = Application.XDocuments(1)
    3 - objNewDoc.DOM.selectSingleNode("//field1").text = "HELLO"
    4 - objNewDoc.Query

    Step 1 - work fine and start bravo.xsn
    Step 2 - no response, but I suppose it work
    Step 3 - Error

    Field1 is first (and last) text field in bravo.xsn form. I suppose there is a formal error, but I don't know where is it. Is this the right way to move a string from alfa to beta or exist another (easy) way?
    Thanks. Raoul
  • 07-21-2006 11:42 AM In reply to

    Re: How to call a form from another one

    Raoul,

    Greg can probably help you better with your specific question but I thought I would pass on this link that I have used to successfully pass variables to a new form.

    http://www.geekswithblogs.net/bpaddock/archive/2004/05/14/4907.aspx
  • 07-21-2006 03:52 PM In reply to

    Re: How to call a form from another one

    A minor change to what you've got because you have no way to guarantee that XDocuments(1) is "really" the new form you just opened. It could be a different form, if you have others open.

    1 - Set objNewDoc = Application.XDocuments.NewFromSolution("urn:bravo:Myname")
    2 - objNewDoc.DOM.selectSingleNode("//field1").text = "HELLO"


    As for the query... I'm not positive whether you can do that from a different form... I haven't tried that. You might have to do that from the for you opened and not from the form by which you opened it. Did that make sense? Try it anyway and see if it works or not.
  • 07-23-2006 02:18 PM In reply to

    • Raoul
    • Top 500 Contributor
    • Joined on 05-05-2006
    • Posts 32

    Re: How to call a form from another one

    Hi all,
    thank you for reply.

    Greg, I have hear your answer, but my code don't work yet. I list here my code:

    ######################################################à
    Sub XDocument_OnSubmitRequest(eventObj)

    sStart1 = XDocument.DOM.selectSingleNode("//my:start1").text
    sStart2 = XDocument.DOM.selectSingleNode("//my:start2").text

    'Application.XDocuments.NewFromSolution("urn:Bravo:Raoul")
    Set objNewDoc = Application.XDocuments.NewFromSolution("urn:Bravo:Raoul")

    objNewDoc.DOM.selectSingleNode("//campo1").text = sStart1
    objNewDoc.DOM.selectSingleNode("//campo2").text = sStart2

    End Sub
    #############################################

    Alfa.xsn is starting form, and it contain this code. In it there are two fields named Start1 and Start2, and they are correctly read by initial code (sStart1 and sStart2 contain right values).

    Bravo.xsn have two text fields only (campo1 and campo2).

    I have transform third line in a comment because of fourth line, that appair to open also new form. I have also tryed with it, but no difference about error occurs.

    Error occur on line
    objNewDoc.DOM.selectSingleNode("//campo1").text = sStart1
    Error message (in italian) is:
    "Errore di run-time di microsoft VBScript. Necessario oggetto: 'objNewDoc.DOM.selectStringNode(...)"

    If I modify line like
    objNewDoc.DOM.selectSingleNode("//my:campo1").text = sStart1
    Error message change in:
    "MSXML5.dll: riferimento a un prefisso dello spazio dei nomi non dichiarato: 'my'."

    I suppose that field campo1 is not find, but I dont't know why. If you have an email address, for you convenience I can send you my code.
    Thank you. Raoul

    p.s.: possible Namespaces problems? This is my definition:
    XDocument.DOM.setProperty "SelectionNamespaces", "xmlns:my=""http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-06-23T08:54:55"""
  • 07-24-2006 03:51 PM In reply to

    Re: How to call a form from another one

    Yes, I think you are right about the namespace issue. As I was reading through your latest scenario, the same thought crossed my mind. You will need to use .setProperty() on objNewDoc after it gets Set. You will need to find out what the namespace is in Bravo.xsn and use that value in the setProperty() method.

    Once you've established the namespace in the new DOM, then you should be able to properly select a node and set its value.
  • 07-25-2006 12:39 AM In reply to

    • Raoul
    • Top 500 Contributor
    • Joined on 05-05-2006
    • Posts 32

    Re: How to call a form from another one

    All Right !
    I have just insert a
    objNewDoc.DOM.setProperty ...
    line after Set of new object and all work fine now!
    Thank you very much for your support.
    Grazie. Raoul
Page 1 of 1 (10 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.