Insert Value into Expression Box inside Repeating Table - InfoPath Dev
in

InfoPath Dev

Insert Value into Expression Box inside Repeating Table

Last post 03-02-2011 07:20 AM by wbeard52. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 03-01-2011 07:56 AM

    Insert Value into Expression Box inside Repeating Table

    Hi,

     

    I found this code on this forum and it works great to get the number of repeating sections I need onto the form.  I am now trying to get a number into the @QuestionNumber node in each repeating section.  I can't seem to figure it out.  Unfortunately, there are no errors given and the value is not inserted into the correct node.  The part after Dim Qstn is the code in question.  Thanks for helping me.

    'set the query fields

    Dim xpath As String = "/dfs:myFields/dfs:dataFields/d:Tests/@NumberofQuestions"

    Dim field As XPathNavigator = Me.DataSources("Tests").CreateNavigator().SelectSingleNode(xpath, NamespaceManager)

    'get the node you wish to have repeated

    xpath = "/dfs:myFields/dfs:dataFields/d:Annual_Test_Results/d:AnnualTestAnswers"

    Dim group As XPathNavigator = MainDataSource.CreateNavigator().SelectSingleNode(xpath, NamespaceManager)

    'cast the field's value to an int to know how many rows to add

    Dim rows As Integer = field.ValueAsInt

    'loop, cloning group

    Dim i As Integer

    For i = 1 To rows - 1Dim newRow As XPathNavigator = group.Clone()

    newRow.InsertAfter(group)

    Dim Qstn As XPathNavigator

    Qstn = group.CreateNavigator().SelectSingleNode(xpath & "/@QuestionNumber", NamespaceManager)

    Qstn.SetValue(Convert.ToString(i))

    Next i

  • 03-01-2011 08:32 AM In reply to

    Re: Insert Value into Expression Box inside Repeating Table

    Try this instead:

    Qstn = group.CreateNavigator().SelectSingleNode("@QuestionNumber", NamespaceManager)

    Hilary Stoupa

  • 03-01-2011 10:06 AM In reply to

    Re: Insert Value into Expression Box inside Repeating Table

    Locked Reply Contact

    Thanks Hilary for the quick response.  It is greatly appreciated.  I tried what you gave me to no success.  I thought it was quite strange so I converted the expression box to a textbox and ran the form again.  This time I provided a value in the textbox and the moment the textbox lost focus the value disappeared.  It did it for every section.  I pulled up the property for the text box and noticed the checkmark next to "Update this value when the result of the formula is recalculated".  I deselected this feature and the code worked with your revised xPath.

     I appreciate it.

  • 03-02-2011 07:20 AM In reply to

    Re: Insert Value into Expression Box inside Repeating Table

    I can go about and place values into a textbox now using the above code.  How would I later pull out different values from the repeating section through code?  More specifically, I need to pull out the @Answer node for each repeating section.  Thanks for your help

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