OnClick code only running for first instance of repeating section - InfoPath Dev
in

InfoPath Dev

OnClick code only running for first instance of repeating section

Last post 05-29-2009 08:12 AM by kminor. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 05-13-2009 09:33 AM

    OnClick code only running for first instance of repeating section

    Hello, I am stumped and could use some help.  I began researching an answer (both here and on the web) yesterday, and I'm still not even close, I'm afraid.

    I created a form in InfoPath 2003 that uses a repeating section to enter customer data.  It has a button at the bottom of the page.  I've written some validation code that runs in the on-click event of the button.

    The problem I'm having is that when the code in the on-click event runs, it only looks at the first instance of the repeating section.  I'm trying to figure out how to loop through all the instances of the repeating section to have the validation code check each instance.  I believe I need to use SelectNodes, but I can't figure out where to go with it.

    My data structure looks like:

    myFields

    - dataFields

    -- d:Requests

    --- Customers   <-- this is where the data for the repeating section is.

     

    Any help would be greatly appreciated!

     

    ETA:  I tried the code below (trying to figure out what's what).  After I submitted a form with 2 instances of the repeating section, objXMLNodes.count was still equal to 1.  Am I going about this the wrong way?

         Set objXMLNode = XDocument.DOM.selectSingleNode("//dfs:dataFields/d:Requests/d:Customers")

         XDocument.View.SelectNodes(objXMLNode)

         Set objXMLNodes = XDocument.View.GetSelectedNodes

         If (objXMLNodes.Count > 0) then

              XDocument.UI.Alert(objXMLNodes(0).nodeName + "\n\n" + objXMLNodes(0).text)

         End if

     

    -- Kelley
  • 05-15-2009 07:27 AM In reply to

    Re: OnClick code only running for first instance of repeating section

    Still looking for help on this, if anyone has any to offer.  Please, and thank you!  :)

    -- Kelley
  • 05-19-2009 07:33 AM In reply to

    Re: OnClick code only running for first instance of repeating section

    I hate to be a pest, but I still haven't figured this out.  Can anyone help, please?

    -- Kelley
  • 05-20-2009 03:56 PM In reply to

    Re: OnClick code only running for first instance of repeating section

    Hi, so you are using vbscript?

    Dim objXMLNodes
    Set objXMLNodes = XDocument.DOM.selectNodes("/my:myFields/my:group/my:repeatinggroup")
        for each node in objXMLNodes
           XDocument.UI.Alert(node.nodeName + VBNewLine + node.text)
      next

    I'm attaching my sample form. In the header of this reply, right click the link and use Save As to save locally. Right click the saved form and open in design mode. Preview and click the button....

    Hilary Stoupa

  • 05-28-2009 06:07 AM In reply to

    Re: OnClick code only running for first instance of repeating section

    Hilary -- thank you SO much!  I apologize for taking so long to get back to you on this; I've been eyeball-deep in a couple of other projects, too.  I hate being in that newbie stage of learning new technology because I know what needs to happen in code; I just can't figure out the syntax!  :)
    -- Kelley
  • 05-29-2009 08:12 AM In reply to

    Re: OnClick code only running for first instance of repeating section

    Hilary, I used your script as a starting point, and my form is finally doing what I need it to do!

    In case anyone else might have the same issue down the road, here is an example of the syntax I used within the "For... Next" loop to access the individual text boxes in the repeating section:

    Set shipToNum = node.selectSingleNode("@ShipToNum")

    Remember that "node" was set in Hilary's script.

    Thanks again -- you've been a huge help.  Hope you have a great day!

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