button to add new row(s) to repeating table (infopath 2010 VB) - InfoPath Dev
in

InfoPath Dev

button to add new row(s) to repeating table (infopath 2010 VB)

Last post 05-28-2012 12:49 PM by SPowell. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 11-25-2011 02:23 AM

    • paolo
    • Not Ranked
    • Joined on 11-25-2011
    • Posts 20

    button to add new row(s) to repeating table (infopath 2010 VB)

     Hallo,

    I would like to create a button to add a new row to a repeating table programmatically in infopath 2010

    (such that the user can add more records if needed).

    (I am aware you don't really need to code that, but I would like to implement that in VB code as

    a basis for future more advanced functions - so I am trying to learn how it works).

    In the button code ( "clicked" procedure) I was trying the following code

     Dim MainRepeatingTable As XPathNavigator
     MainRepeatingTable = Me.MainDataSource.CreateNavigator
     MainRepeatingTable.SelectSingleNode("//dfs:dataFields/d:myRepeatingTableGroup", NamespaceManager).AppendChild()

    But this is not working... No errors, but also no changes in the shown repeating table.

    I would be grateful if someone could provide some hints for me.

    Thanks,

    Paolo

     

  • 11-25-2011 02:32 AM In reply to

    Re: button to add new row(s) to repeating table (infopath 2010 VB)

    Hi Paolo,

    This works on 2003 hopefully this will work on 2010 also.

    First you need to check the properties of the repeating section, you're looking for something called the xCollection (please note this will be different for each instance of the repeating section), lets say for example repeatingGroup_75.

    You can then use the following code

    on error resume
    xDocument.View.executeAction "xCollection::insert", "repeatingGroup_75"

    I've added the on error resume so that if you use the same button on different views it can try all of them until it hits the right xCollection for the view

    I've just noticed you're asking for a solution for repeating tables where as this is for repeating sections, it might work though.

     Cheers

    K

  • 11-25-2011 04:12 AM In reply to

    • paolo
    • Not Ranked
    • Joined on 11-25-2011
    • Posts 20

    Re: button to add new row(s) to repeating table (infopath 2010 VB)

    Hallo Kear,

     

    thanks for your answer.

    When looking at the properties of my repeating table, I can see 4 tabs - Data,Display,Master/Detail,Advanced. None of them has xCollection mentioned anywhere...

    I did notice the single fields have somethging like

    ViewContext: CTRL 39

    but that's all I could find...

     

     

  • 11-25-2011 04:42 AM In reply to

    Re: button to add new row(s) to repeating table (infopath 2010 VB)

    Paolo,

     On 2003 xCollection can be seen on the Advanced tab and it's under a heading 'Code: xmlEdit Names'

     K

  • 11-25-2011 05:08 AM In reply to

    • paolo
    • Not Ranked
    • Joined on 11-25-2011
    • Posts 20

    Re: button to add new row(s) to repeating table (infopath 2010 VB)

     I only see accessibility and form merging options in 2010 under the advanced tab

  • 11-25-2011 06:21 AM In reply to

    Re: button to add new row(s) to repeating table (infopath 2010 VB)

    According the page below it should definitly be under the Advanced Tab (can't confirm as I'm using 2003)

    Just go here and do a search for xCollection that might give you an idea of where to look.

    http://office.microsoft.com/en-us/infopath-help/controls-101-choice-groups-HA001118518.aspx

  • 05-28-2012 12:49 PM In reply to

    Re: button to add new row(s) to repeating table (infopath 2010 VB)

    Hey there, I'm using this exact code to generate a new repeating table row from a button and I'm getting an error in my code that says XDocument is not declared. I'm not very good with InfoPath VB, however I thought XDocument was some sort of default global variable to refer to the current document, so this isn't entirely making sense to me. I've also tried thisXDocument, and Me. however nothing works. I am using InfoPath 2007. Please let me know what I'm doing wrong, I'm getting a little desperate here. Thank you so much.
Page 1 of 1 (7 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.