Group:  Microsoft Access ยป microsoft.public.access.modulesdaovba
Thread: Filtering query results using a ListBox In Access 2000

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Filtering query results using a ListBox In Access 2000
SEAN DI''''ANNO 08.09.2006 08:16:02
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
Re: Filtering query results using a ListBox In Access 2000
"Duane Hookom" <DuaneAtNoSpanHookomDotNet> 08.09.2006 15:52:31
There is a generic list box function at
http://www.rogersaccesslibrary.com/OtherLibraries.asp#Hookom,Duane. This can
be used in your maketable query.

--
Duane Hookom
MS Access MVP

"SEAN DI''''ANNO" <SEANDIANNO[ at ]discussions.microsoft.com> wrote in message
news:9B179628-3E74-4B93-849B-ED04566F46AA[ at ]microsoft.com...
[Quoted Text]
> 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


Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net