list box help (adding/removing)

QuietRiot

Registered User.
Local time
Today, 06:36
Joined
Oct 13, 2007
Messages
71
Hi all,

I have 2 list boxes on my form. List7 and List9. List7 gets populated with a query. I want to have two arrow buttons that will move items from List7 to List9 and then from list9 to List7 if needed. Also I need it so if list7 has an item selected and then I click on list9 and select an item that list7 box is not highlighted/selected anymore and vise versa.

issue with my add code so far is that it moves items on the 2nd spot of the list9 for some reason and the first item in list9 is a blank. Also it doesn't remove it from list7 yet either.

Any help...

Code:
Private Sub AddButton_Click()

Dim str As String, mainstr As String
  Dim c As Control
    Dim introw As Integer

Set c = Me.List7
  str = ""

  For introw = 0 To (c.ListCount - 1)
    
    If c.Selected(introw) Then
      str = str & c.Column(0, introw) & ","
    End If
  
  Next introw

str = Left(str, Len(str) - 1)

mainstr = Me.List9.RowSource & ";" & str
mainstr = Replace(mainstr, str & ";", "", 1)
Me.List9.RowSource = mainstr
  Me.List9.RowSourceType = "value list"
    Me.List9.Requery

End Sub
 

Users who are viewing this thread

Back
Top Bottom