Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Atlanta, Georgia, USA
    Posts
    274
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ListBox count (Access2K)

    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

  2. #2
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Minneapolis, Minnesota, USA
    Posts
    262
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ListBox count (Access2K)

    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:<pre>Private Sub lstTest_AfterUpdate()
    Dim intNumChoices As Integer

    intNumChoices = Me.lstTest.ItemsSelected.Count

    Me.txtCount.Value = intNumChoices

    End Sub</pre>

    Good luck!
    <font face="Comic Sans MS"><font color=blue>~Shane</font color=blue></font face=comic>

  3. #3
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Atlanta, Georgia, USA
    Posts
    274
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ListBox count (Access2K)

    Thanks, That worked Great
    Happy Holidays

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •