Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9255411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:42:43+00:00 2026-06-18T11:42:43+00:00

I have two listboxes and am trying to add items from List 1 to

  • 0

I have two listboxes and am trying to add items from List 1 to List 2, and then be able to remove multiple items from List 2 at once. Note that List 1 stays stagnant (this is how it is supposed to be).

I have the adding items working right:

'Add the selected items to List 2
Dim i As Integer

If lst1.ItemsSelected.Count > 0 Then
    i = 0
    While i < lst1.ListCount
        If lst1.Selected(i) Then
            lst2.AddItem (lst1.ItemData(i) & ";" & lst1.Column(1, i) & ";")
            lst1.Selected(i) = False
        End If
        i = i + 1
    Wend
End If

However, when I try to remove the items from List 2 in a similar way, it only recognises the first selected item as selected and skips over the other items that I have selected. This is the problem. Here is my code:

'Remove the selected items from List 2
Dim i As Integer

If lst2.ItemsSelected.Count > 0 Then
    i = lst2.ListCount - 1
    While i >= 0
       If lst2.Selected(i) Then
           lst2.RemoveItem (i)
           lst2.Selected(i) = False
       End If
        i = i - 1
    Wend
End If

How can I get this working correctly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T11:42:44+00:00Added an answer on June 18, 2026 at 11:42 am

    As far as I can tell, as soon as you remove one item, all items become unselected, so:

    Dim itm As Variant
    Dim srem As String
    Dim asrem As Variant
    
        For Each itm In lst2.ItemsSelected
            srem = srem & "," & itm
        Next
    
        asrem = Split(Mid(srem, 2), ",")
        For i = UBound(asrem) To 0 Step -1
            lst2.RemoveItem lst2.ItemData(asrem(i))
        Next
    

    Note also that this is Access and you are dealing with a value list, so Replace on the text of Row Source will also work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two list boxes that I am trying to pass multiple values from
I have two ListBoxes. First ListBox items are list of Products. and second ListBox
I have two listboxes that I am dragging one item from to the other.
I am trying to create a control which contains two listboxes with add/remove buttons
I have two ListBoxes, lstAvailableColors and lstSelectedColors. Between each listbox are two buttons, Add
I am trying to implement drag and drop between two listboxes. I have a
I am trying to implement a list that contains items of a certain type,
I have two listboxes. The listbox1 contains a list of the DB names. Listbox2,
I have a view that contains 2 list boxes: Audience & Locale I'm trying
I have a listbox that is populated with a list of List items. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.