title: MS Access multi-select list mover v2
body: <p>As an extension to the previous post listed below:</p>
  
  <p><a href="https://stackoverflow.com/questions/44990548/ms-access-multi-select-listbox-mover/44992375?noredirect=1#comment77010404_44992375">Ms Access multi-select listbox mover</a> </p>
  
  <p>I received great help from some of the community members here (Shout out to @Parfait for his continued assistance and @Erik Von Asmuth) in regards to a problem I was experiencing in coding a multi-select list mover. </p>
  
  <p>The first problem has been resolved, however, I am experiencing a new problem in the excution on cmdRemove_Click() button. The problem is as follows:</p>
  
  <p>I have two list boxes (lfmVocabulary and lfmVocabularyAssign). The first list box (lfmVocabulary) has a multi-select function to choose vocabulary words to be assigned to a unit, thus transferred into the lfmVocabularyAssign list box. I can select and transfer the .selected with no problems (thanks to the community), now I have a problem sending them back from the lfmVocabularyAssign list box to the lfmVocabulary.</p>
  
  <p>Say I have Vocabulary words A, B, and C. I select A &amp; B to be transferred, hit cmdAdd and no problems. But if I select A &amp; B and hit cmdRemove to transfer them back to the first list box, C takes the place of A &amp; B in the second list box!</p>
  
  <p>Here is my code:</p>
  
  <pre><code>Option Compare Database
  
  
  Private Sub cmdAdd_Click()
  
  Dim in_clause As String: in_clause = ""
  Dim strSQL As String, i As Integer
  
  ' ITERATE TO BUILD COMMA-SEPARATED LIST FOR SQL IN() CLAUSE
  With Me.lfmVocabulary
      For n = 0 To .ListCount - 1
         If .Selected(n) = True Then
             in_clause = in_clause &amp; .ItemData(n) &amp; ", "
         End If
      Next n
  End With
  
  ' REMOVE LAST COMMA AND SPACE
  in_clause = Left(in_clause, Len(in_clause) - 2)
  
  strSQL = "SELECT * FROM qryVocabularyDefinitions" _
             &amp; " WHERE VocabSpeechDefID IN (" &amp; in_clause &amp; ")"
  
  Me.lfmVocabularyAssign.RowSource = strSQL
  Me.lfmVocabularyAssign.RowSourceType = "Table/Query"
  Me.lfmVocabularyAssign.Requery
  
  End Sub
  
  Private Sub cmdClearAll1_Click()
  
   Dim n As Integer
  
      With Me.lfmVocabulary
          For n = 0 To .ListCount - 1
              .Selected(n) = False
          Next n
      End With
  
  End Sub
  
  Private Sub cmdClearAll2_Click()
  
   Dim n As Integer
  
      With Me.lfmVocabularyAssign
          For n = 0 To .ListCount - 1
              .Selected(n) = False
          Next n
      End With
  
  End Sub
  
  Private Sub cmdRemove_Click()
  
  Dim in_clause As String: in_clause = ""
  Dim strSQL As String, i As Integer
  
  ' ITERATE TO BUILD COMMA-SEPARATED LIST FOR SQL IN() CLAUSE
  With Me.lfmVocabularyAssign
      For n = 0 To .ListCount - 1
         If .Selected(n) = True Then
             in_clause = in_clause &amp; .ItemData(n) &amp; ", "
         End If
      Next n
  End With
  
  ' REMOVE LAST COMMA AND SPACE
  in_clause = Left(in_clause, Len(in_clause) - 2)
  
  strSQL = "SELECT * FROM qryVocabularyDefinitions" _
             &amp; " WHERE VocabSpeechDefID NOT IN (" &amp; in_clause &amp; ")"
  
  Me.lfmVocabularyAssign.RowSource = strSQL
  Me.lfmVocabularyAssign.RowSourceType = "Table/Query"
  Me.lfmVocabularyAssign.Requery
  
  End Sub
  
  Private Sub cmdSelectAll1_Click()
  
   Dim n As Integer
  
      With Me.lfmVocabulary
          For n = 0 To .ListCount - 1
              .Selected(n) = True
          Next n
      End With
  
  End Sub
  
  
  Private Sub cmdSelectAll2_Click()
   Dim n As Integer
  
      With Me.lfmVocabularyAssign
          For n = 0 To .ListCount - 1
              .Selected(n) = True
          Next n
      End With
  End Sub
  
  Private Sub cmdAssign_Click()
  
  :(
  
  End Sub
  
  Private Sub Form_Load()
  
      Me.lfmVocabulary.RowSource = "qryVocabularyDefinitions"
      Me.lfmVocabulary.RowSourceType = "Table/Query"
      Me.lfmVocabulary.Requery
  
  End Sub 
  </code></pre>