setvalue in vb no working - InfoPath Dev
in

InfoPath Dev

setvalue in vb no working

Last post 11-07-2011 06:04 AM by jfrade. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 11-06-2011 08:48 PM

    setvalue in vb no working

    May I have help with the following error? 

     {"Operation is not valid, because of the current state of the object."}

    I have one multiple selection listbox which I wish to populate into one textbox field.  I loop through the selected items which are nonempty and store into a string.  I am getting the above error on the SetValue method.  Thanks for your help.

    Public Sub Model_ListBox_Changing(ByVal sender As Object, ByVal e As XmlChangingEventArgs)

    ' Ensure that the constraint you are enforcing is compatible

    ' with the default value you set for this XML node.

    ' Write your code here

    Dim root As XPathNavigator = MainDataSource.CreateNavigator()

    Dim iter As XPathNodeIterator = root.Select( _

    "/my:myFields/my:group1/my:group2/my:group3/my:Model_ListBox", NamespaceManager)

    Dim sb As System.Text.StringBuilder = New System.Text.StringBuilder()

    While (iter.MoveNext())

    Dim value2 As String = iter.Current.Value

    If value2 <> "" Then

    sb.AppendFormat(value2)

    sb.AppendFormat(
    ";")

    End If

    End While

    root.SelectSingleNode("//my:Model_ListBox_Collapsed", _

    NamespaceManager).SetValue(sb.ToString())

    End Sub

  • 11-06-2011 11:09 PM In reply to

    Re: setvalue in vb no working

    Hello jfrade,

    You can't change DOM values during a BeforeChange or Changing event.  You'll have to put them in the AfterChange event.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 11-07-2011 06:04 AM In reply to

    Re: setvalue in vb no working

    Hello Jimmy,

    Perfect, changed the following, and all worked.  Thanks for quick response.  No more questions on this topic.  Have a good day.

    Public Sub Model_ListBox_Changed(ByVal sender As Object, ByVal e As XmlEventArgs)

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