Question How to use filteron with a listbox

josephbupe

Registered User.
Local time
Today, 08:42
Joined
Jan 31, 2008
Messages
247
Hi,

Please, how can I use the filteron property on a list box?

I want to filter a listbox named "lstPersons" in a form "F_Wanted_Menu" based on what is typed in in a textbox on the same form. Initially, this worked well with a continuous form, which I have decided to replace with a list box:

Code:
Forms!F_Wanted_Menu!lstPersons.FILTER = "MySearch Like '*" & Nz(Me.txtSearch.Value, "") & "*'"
Forms!F_Wanted_Menu!lstPersons.FilterOn = True

I will appreciate your help.

Regards

joseph
 
There is no filter property for listboxes.

Assuming the rowsource is SQL rather than a query (i.e. copy the query's SQL into the rowsource istead of the query name) you could try something like this:

Code:
Forms!F_Wanted_Menu!lstPersons.RowSource = Forms!F_Wanted_Menu!lstPersons.Row Source & _
    " [B]AND[/B] MySearch Like '*" & Nz(Me.txtSearch.Value, "") & "*'"

The AND assumes the existing SQL already has a WHERE clause, if not replace it with WHERE.
 
Hi Brighton,

It worked! Thanx alot.

Stay well
 

Users who are viewing this thread

Back
Top Bottom