Filtering query results using a ListBox In Access 2000

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Good morning all,

I managed to get the code below to choose ultiple entrues in a listbox and
then filter a report using strwhere. I was hoping I could use the same
technique to run a make table query filtering the results also by strwhere.
In the code below, SelectCategory is the name of the listbox and I am using
it to allow users to choose names from a list. THerefore the query pulls out
froma database all the entries with the names chosen. Can some one please
be kind enough to provide me with code for acheiving this.

Thank you in advance

With Me.SelectCategory
For Each varItem In .ItemsSelected
If Not IsNull(varItem) Then
'Build up the filter from the bound column (hidden).
strWhere = strWhere & strDelim & .ItemData(varItem) &
strDelim & ","
'Build up the description from the text in the visible
column. See note 2.
strDescrip = strDescrip & """" & .Column(1, varItem) & """, "
End If
Next
End With

'Remove trailing comma. Add field name, IN operator, and brackets.
lngLen = Len(strWhere) - 1
If lngLen > 0 Then
strWhere = "[OperatorName] IN (" & Left$(strWhere, lngLen) & ")"
lngLen = Len(strDescrip) - 2
If lngLen > 0 Then
strDescrip = "TeamName: " & Left$(strDescrip, lngLen)
End If
End If


Me.QueryFilter = strWhere
 
Back
Top