Problem with Repeating Table in Repeating Section - InfoPath Dev
in

InfoPath Dev

Problem with Repeating Table in Repeating Section

Last post 01-20-2010 09:24 PM by Qazi Anis. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 01-15-2010 02:53 AM

    Problem with Repeating Table in Repeating Section

     Hi, everybody!

    As a total newbee to InfoPath (and therefore also to this forum) I hope I can get some help from you experts to solve a (maybe very simple) problem dealing with a repeating table in a reapeting section in a form. The requirement is that if the user clicks "insert item" in the repeating section the entire repeating table (which itself is a member of the mentioned repeating section) MUST be copied including all its formerly entered values into the new generated repeating section. How can this be done (using rules or programming VBA)?

    Thanks in advance!

  • 01-15-2010 06:03 AM In reply to

    Re: Problem with Repeating Table in Repeating Section

    you will have to do this using VBA. i dont know of any other way. A sample code will be

    XPathNodeIterator listItemNav = this.MainDataSource.CreateNavigator().Select("my:myFields/my:group1/my:group2", this.NamespaceManager);

    for (int i = 0; i < listItemNav.Count; i++, listItemNav.MoveNext()) ;

    listItemNav.Current.Clone().InsertAfter(listItemNav.Current);

    Qazi Anis
    Technical Architect
    Bitwise Inc
  • 01-15-2010 09:46 AM In reply to

    Re: Problem with Repeating Table in Repeating Section

     Thanks Qasi! I'll try this and feedback.

  • 01-15-2010 11:21 AM In reply to

    Re: Problem with Repeating Table in Repeating Section

    Thank you Qazi, this helped me solve my problem with my form.

  • 01-15-2010 01:40 PM In reply to

    Re: Problem with Repeating Table in Repeating Section

    Oh one question though.. how do I assign values to a field in both the cloned section and the original one?

    There's a field (Version) in the repeating section that I want to automatically set to 1.00 for the original copy and increment the value for the succeeding cloned sections.

    Any help would be greatly appreciated. Thanks.

    - Ric

  • 01-19-2010 03:08 AM In reply to

    Re: Problem with Repeating Table in Repeating Section

    Hi, Qasi!

    Unfortunately your codesnippet (after some modifictions and adaptions) did not work properly! Obviously I made some severe mistakes and did not understand the VBA eventhandling and the InfoPath XPath expression evaluation very well. I designed a very simple form consisting of a repeating section including a repeating two column table. I put the VBA code into the changed event of the repeating section but the program (VBA debugger) crashed as soon as I wanted to enter some data into the repeating table telling me of an unallowed operation in the current status of the repeating section. The other two event classes crashed in the same way. I then put a copy-button in the repeating section with the "copy-repeating-table"-code. I entered data into the repeating table then inserted a new section and clicked the copy button. The effect was that the repeating section was generated exactly four times and each instance including the repeating table (with the formerly entered data, as desired!). I then tried to modify the for loop in your proposal with even more strange effects (only one repeating section instance but four instances of the repeating table in it). So, my opinion is that there is something wrong with the XPath-expression in my code. The datasource InfoPath generated from my design is as follows:

     myFields

        group1

            group2

                group3

                   group4

                       field1

                       field2

     

    The VBA-code for the copy button currently (state of trial and error) is as follows:

    Public Sub CTRL5_5_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)
                ' Write your code here.
                Dim i As Integer
                Dim path As String = "/my:myFields/my:group1/my:group2"
                Dim listItemNav As XPathNodeIterator = Me.MainDataSource.CreateNavigator().Select(path, NamespaceManager)
                Dim nav As XPathNodeIterator = Me.MainDataSource.CreateNavigator().Select("/my:myFields/my:group1/my:group2[last()-1]/my:group3/my:group4", NamespaceManager)
                'For i = 0 To listItemNav.Count
                'listItemNav.MoveNext()
                nav.Current.Clone().InsertAfter(listItemNav.Current)
                'Next i

            End Sub

     

     

  • 01-19-2010 04:00 AM In reply to

    Re: Problem with Repeating Table in Repeating Section

                Dim i As Integer
                Dim listItemNav As XPathNodeIterator = Me.MainDataSource.CreateNavigator().Select("/my:myFields/my:group1/my:group2", NamespaceManager)
               For i = 0 To listItemNav.Count
               listItemNav.MoveNext()

               Next i
                listItemNav.Current.Clone().InsertAfter(listItemNav.Current);
               

    Qazi Anis
    Technical Architect
    Bitwise Inc
  • 01-20-2010 02:42 AM In reply to

    Re: Problem with Repeating Table in Repeating Section

    Hi, Qasi!

    I'm so sorry but it doesn't work properly yet. It must be something wrong with the XPath expressions and the navigator. Therefore I prepared some screenshots so that you can get an impression on what exactly the design and the underlying code is as well as of the strange (or better "unwanted") results the code produces. My problem now is: how can I mail you this word document. Is it possible to do it as an attachement to a post here or is it better to send it outside InfoPath Dev via normal e-mail?

    v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} Normal 0 21 false false false MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} Many thanks for your engagement

  • 01-20-2010 06:10 AM In reply to

    Re: Problem with Repeating Table in Repeating Section

    you can just put them as attachments here

    Qazi Anis
    Technical Architect
    Bitwise Inc
  • 01-20-2010 07:50 AM In reply to

    Re: Problem with Repeating Table in Repeating Section

    Hi, Qasi!

    It took me some time to find out how to make an attachment, I'm sorry for that. Since the screenshotfile is to big to be send as an attachment I choose to send you the original InfoPath testform. I hope you can open and test it. It is designed with InfoPath2007 and VSTA (VBA).

    The correct use MUST be:

    1. enter data into the first repeating table (at least two rows)

    2. click "insert item"  on the repeating SECTION

    3. click the "Button"-button. Now the first repeating table must be copied into the new repeating section

    4. change the data in the repeating table and continue with steps 2. and 3. .Now the changed repeating table contents MUST be copied into the new section and so on ....

    I hope it becomes clear to you what the difference is to the current behaviour of the code.

    Many thanks and best regards

    Robert Heinzel (Hamburg, Germany)

  • 01-20-2010 09:24 PM In reply to

    Re: Problem with Repeating Table in Repeating Section

    sorry i cant open the zips here, can you please mail them to [email protected].

     

    Qazi Anis
    Technical Architect
    Bitwise Inc
Page 1 of 1 (11 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.