• ListBox count (Access2K)

    Author
    Topic
    #380884

    Is there a way to show how many items are selected in a separate textbox, as they are selected in a multi select listbox?
    Also to subtract from that number if a selection is clicked on then clicked again to remove it.
    Thanks for any help provided

    Viewing 0 reply threads
    Author
    Replies
    • #639617

      There sure is. The magic combination of methods, properties and events are: the AfterUpdate event of your multi-select enabled list box and the ListBox.ItemsSelected.Count property. Whether you click to choose, or click to unchoose a selection in a list box, you’ll fire the AfterUpdate event for the control. You can examine the number of selected items, and do something with it. So, to come close to your scenario, imagine your list box is named lstTest, and the text box is named txtCount. The code would be something like:

      Private Sub lstTest_AfterUpdate()
          Dim intNumChoices As Integer
          
          intNumChoices = Me.lstTest.ItemsSelected.Count
          
          Me.txtCount.Value = intNumChoices
      
      End Sub

      Good luck!

    Viewing 0 reply threads
    Reply To: ListBox count (Access2K)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: