Select All for Multi-Select List Box - InfoPath Dev
in

InfoPath Dev

Select All for Multi-Select List Box

Last post 12-21-2010 08:29 AM by Jimmy. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 12-20-2010 07:46 AM

    Select All for Multi-Select List Box

    I'm trying to add a button to a form that will select all items in a multi-select list box.  The list box itself is buried in a repeating section.  I found this article and tried to modify it for my purposes.  However, I'm getting the "InfoPath cannot open the selected form" error.  I know my problem deals with the syntax that I've put in bold below, but I don't know how to change it.  Any help is appreciated.  Thanks.

    Sub CTRL77_5_OnClick(eventObj)

    Dim divisions(16)

    divisions(0)="Canada"

    divisions(1)="Corporate"

    divisions(2)="ES&P (Clark)"

    divisions(3)="ES&P (DIA)"

    divisions(4)="ES&P (EM)"

    divisions(5)="ES&P (SVS)"

    divisions(6)="ES&P (TRS)"

    divisions(7)="ES&P (Worksite)"

    divisions(8)="INV"

    divisions(9)="IS&R (Spread)"

    divisions(10)="IS&R (TCM)"

    divisions(11)="L&P (ADMS)"

    divisions(12)="L&P (AFP)"

    divisions(13)="L&P (LTC)"

    divisions(14)="L&P (MNL)"

    divisions(15)="L&P (Payout)"

    divisions(16)="REI (TARe)"

    For Each x in divisions

    Dim root As XPathNavigator = MainDataSource.CreateNavigator()

    Dim group1 As XPathNavigator = root.SelectSingleNode("//my:group1/my:Grp_Reporting_Period/my:Grp_Division", NamespaceManager)

    Dim field1 As XPathNavigator = root.SelectSingleNode("//my:group1/my:Grp_Reporting_Period/my:Grp_Division/my:Division_Choice", NamespaceManager)

    Dim newNode As XPathNavigator = field1.Clone()

    newNode.SetValue(x) group1.AppendChild(newNode)

    Next

    End Sub

     

    Filed under:
  • 12-21-2010 04:47 AM In reply to

    Re: Select All for Multi-Select List Box

    Hi there,

    It's too bad that S.Y.M.Wong doesn't have her own forum. We get asked to answer many questions regarding her blog. :)

    Sometimes she graces this site and answers questions. Unfortunately, we don't support other blogs because not all of them use best practices.

    Sorry about that!

    Patrick Halstead
    Project Manager at Qdabra
  • 12-21-2010 07:01 AM In reply to

    Re: Select All for Multi-Select List Box

    Hi Patrick.

    Thanks for the reply.  I know what you mean about her forum.  I would have posted my question there if I could.  On the same note, do you have any suggestions on how to create code that will select all items in a multi-select list box?  Whatever is going on (really, not going on), it has something to do with the XPathNavigator lines.  I just can't get the form to open whenever those lines are active in the code.  What's really frustrating is that this code seems similar to other examples I've seen.  I'm using VBScript (don't have access to VSTA).

    This seems like wanting to have a "select all" option for the multi-select list box would be a typical question, but I haven't found an adequate solution yet.

    Thanks.

  • 12-21-2010 08:29 AM In reply to

    Re: Select All for Multi-Select List Box

    Believe it or not, this is the first time I can recall coming across this question. Multi-select listboxes do not seem to be terribly popular.

    The reason your form won't open is that you're using VBScript, but the code you're borrowing is written for VB.NET on the InfoPath 2007 object model.  Are you and your form users restricted to using IP 2003? 

    Accomplishing this is somewhat tricker in VBScript and converting code from the 2007 OM to 2003 is not a straightforward process.

    This forum is generally provided for assistance with InfoPath's built-in features and we do provide quick troubleshooting of code written for InfoPath, but not new code written from scratch.  We do provide consulting services with several InfoPath MVPs, including myself, and would be happy to provide you with a quality solution should you wish to go that route.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.