Multi-select list box for multi-column query

M

merry_fay

Hi,

I have a list box lstBudVols from which I want users to select 4 items. Once
these are selected, I want to use the selection for each as criteria for a
different column in a query eg select 2010, 2011, 2012, 2013 in the list box,
the output columns would be:
TSL 2010 2011 2012 2013
xx xxx xxx xxx xxx

I've done this earlier already using 2 different list boxes, but it would
not be a smooth, well built database if the user had to select from 4
different lists.

Is there a way of modifying:
For Each vItm In Me.lstBudVols.ItemsSelected
strWhat=etc

I need to define strWhat1=1st selection, strWhat2=2nd selection,
strWhat3=3rd selection & strWhat4=4th selection

Thanks
merry_fay
 
W

Wolfgang Kais

Hello "merry_fay".

merry_fay said:
I have a list box lstBudVols from which I want users to select 4
items. Once these are selected, I want to use the selection for
each as criteria for a different column in a query eg select
2010, 2011, 2012, 2013 in the list box, the output columns would be:
TSL 2010 2011 2012 2013
xx xxx xxx xxx xxx

I've done this earlier already using 2 different list boxes, but it
would not be a smooth, well built database if the user had to select
from 4 different lists.

Is there a way of modifying:
For Each vItm In Me.lstBudVols.ItemsSelected
strWhat=etc

I need to define strWhat1=1st selection, strWhat2=2nd selection,
strWhat3=3rd selection & strWhat4=4th selection

With Me.lstBudVols
If .ItemsSelected.Count <> 4 Then
MsgBox "You must select 4 items", vbExclamation
Else
strWhat1 = .ItemData(.ItemsSelected(0))
strWhat2 = .ItemData(.ItemsSelected(1))
strWhat3 = .ItemData(.ItemsSelected(2))
strWhat4 = .ItemData(.ItemsSelected(3))
End If
End With
 
M

merry_fay

That's fantastic. Thankyou!!

I slightly modified it to get a column other than the first one from the
list & it still works (somewhat amazingly given my limited skills!):

strWhat1 = .Column(1, .ItemsSelected(0)) etc

:)
merry_fay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top