Unbound multi select list box

  • Thread starter Thread starter Roger Withnell
  • Start date Start date
R

Roger Withnell

To read which items have been selected, I can:
- Count the number selected with ListControl.ItemsSelected.Count
- Collect the indexes of the items selected with
ListControl.ItemsSelected.Item(n)
- Run the indexes against the RowSource to find the value of the items
selected.

Is there an easier way?
 
Hi Roger,

Have you tried something like this?

Private Function IncludeCategories() As String
On Error GoTo ProcError
'-- Create the Categories Where portion of the SQL statement

Dim varCategory As Variant
Dim strTemp As String

'-- for each of the items in the ItemsSelected collection
For Each varCategory In Me!lboCategoryToInclude.ItemsSelected()

strTemp = strTemp & "[CategoryCode] = " & _
Me!lboCategoryToInclude.ItemData(varCategory) & " Or "
Next

If Len(strTemp) > 0 Then
IncludeCategories = "(" & Left$(strTemp, Len(strTemp) - 4) & ")"
Else
IncludeCategories = ""
End If

ExitProc:
Exit Function
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure IncludeCategories..."
Resume ExitProc

End Function




Tom
_________________________________________

:

To read which items have been selected, I can:
- Count the number selected with ListControl.ItemsSelected.Count
- Collect the indexes of the items selected with
ListControl.ItemsSelected.Item(n)
- Run the indexes against the RowSource to find the value of the items
selected.

Is there an easier way?
 

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

Back
Top