Multi-select multi column list box

  • Thread starter Thread starter merry_fay
  • Start date Start date
M

merry_fay

Hi,

I'm using a 'simple' selection list box with multiple columns as criteria
for a query running on my form.

I've written the code:

For Each vItm In Me.lstBud.Column(0).ItemsSelected
strWhat = strWhat & "'" & Me.lstBud.Column(0).ItemData(vItm) & "', "
Next vItm

For Each vItm In Me.lstBud.Column(3).ItemsSelected
strWhat1 = strWhat1 & Me.lstBud.Column(3).ItemData(vItm) & ", "
Next vItm

(column(0) is text & column(3) is not)
but it's coming up with the error Run-time error '424': Object Required in
relation to 'Me.lstBud.Column(0).ItemsSelected'
Is there a way to use data from different columns in a list box as criteria
when multi-select is used?

Thanks
merry_fay
 
Merry_fay -

The ItemsSelected collection is on the control, not on a column, so remove
the .column(0) in your For Each constructs, like this:

For Each vItm In Me.lstBud.ItemsSelected
 
I've changed that bit, but I'm still struggling to set the criteria for the
different columns of the listbox.

This brings back the same criteria for each selection even though they're
different:
For Each vItm In Me.lstBud.ItemsSelected
strWhat = strWhat & "'" & Me.lstBud.Column(3) & "', "

And this has the same control problem:
For Each vItm In Me.lstBud.ItemsSelected
strWhat = strWhat & "'" & Me.lstBud.Column(3).ItemData(vItm) & "', "

How do I get it to use the data from columns other than the first one in the
listbox?

Thanks
 
Merry_fay -

Include the 'row' with the column - like this:

For Each vItm In Me.lstBud.ItemsSelected
strWhat = strWhat & "'" & Me.lstBud.Column(3, vItm) & "', "
 
Back
Top