VBA not working for a Multiselect Listbox

I don't see what Vcode is or where it comes from, so my guess is that's Null. Adding

Debug.Print strSQL

will let you examine the SQL string in the Immediate window.
 
I think that's why JAL put in:

Code:
"AND LeftTable.Vcode = '" & ctl.Column(0, VarItem) & "'"
 
As I was looking at the SQL word by word I noticed in the AND statement the word PartNo. The correct name is Part. I have changed this and now it appears to be working. When you stare at something wrong long enough it looks right.

I apologize, I screwed up here. I should have seen that right off. I appreciate all of your input into my problem (which was my problem) and as usual you have me working. Jal thanks for the tip on the possiblity of double entries; until you said it it hadn't entered my mind.
 
One more question regarding the Listbox. Is there a VBA command to unselect the listbox selections once they are used?
 
I haven't worked with a multiselect. With a single-select, i think the code for deselection would be this:

listbox1.Value = null
 
This type of thing is one way:

Code:
  Dim ctl           As Control
  Dim i             As Integer

  Set ctl = Me.lstCharges

  For i = 0 To ctl.ListCount - 1
    ctl.Selected(i) = False
  Next i
 

Users who are viewing this thread

Back
Top Bottom