RE: Access 07 Use multiselect listbox to filter report

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Yeah the first solution didnt work. But the concatenation worked great. I
still have to do some more testing but all looks good. I made a seperate
query to base the report and Listbox off of. My main query deals with nulls
in the sub field and i didnt feel like messing with it. It only opens in SQL.
And i changed the rowsource of the listbox from Select from Item master to
Select distinct from the New Query.Expr1. So thank you for all your help, it
is greatly appreciated. But while i have your focus i have one more question
if i may. i am now trying to create a Find As You Type Function for the
MultiSelect Listbox. From what i am reading i dont think it can be done.
There are just alot of [ItemNumbers] and scrolling seems like a waste of
time. Ive copied the module from Allen Brownes site but it states that it
doesnt work with unbound controls.

If i have to scroll so be it. But again thanks for the help.

"code_monkey_number_9" wrote:

Based on the error you are receiving, it sounds as if the hack is executing
prematurely. It needs to execute AFTER this block:

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

BUT, based off your explanation of what you are doing, I no longer believe
this will work for you. If I am reading that correctly, your query needs to
return values based on pairs of data, e.g. B784 & Green, B784 & Blue, etc.
While the method above would return those values, it would also return B784 &
Purpl, if that record existed.

So what I think you could do instead is create a concatenated field in the
query that fills your multi-select listbox:

"Select ItemNumber & ItemColor As ItemNumberColor, ItemNumber, ItemColor
From ...". Use this field as the bound column, and include the same field in
qryMain. Then restructure Allen's code to build the where clause from that.
You no longer need the hack.

Does that make any sense?


.



Relevant Pages

  • Re: Sorting listbox contents
    ... Sort list box by column when column is right-clicked ... 'Install call to this code in the Mouse Down event of a listbox. ... Dim iLoop As Integer ... MsgBox "List box must use a query as it's row source" ...
    (microsoft.public.access.modulesdaovba)
  • Re: REPOST: Problem With Listbox Selected Property
    ... The queries are shown below. ... the first query is very simple and the second query is a ... year has not been selected in the lstFY listbox. ... >>> sub procedure. ...
    (microsoft.public.access.modulesdaovba)
  • Re: Help - Cant understand Code
    ... Listbox with MultiSelection used in Query ... I have the sample database in its orignial form. ... The subform doesn't have a SELECT statement however the query it is bound ...
    (microsoft.public.access.forms)
  • a special type of search form
    ... The list of all records you saw was probably a ListBox. ... Private Sub List1_DblClick ... You can also set criteria in your query based on values on ... >the form would be a list of every record in the database, ...
    (microsoft.public.access.forms)
  • Re: Now it works... now it doesnt... What is up with this query
    ... I would like to use this query again. ... FROM [SELECT ItemNumber, CountAS Stores ... The "save parser" chokes on any brackets within a subquery ...
    (microsoft.public.access.queries)