list box driving filter..

matee

New member
Local time
Today, 13:20
Joined
Sep 17, 2003
Messages
7
Hello..
I'm trying to do this for 3 days and nothing..
this is what i have:
2 tables: Company and Region
1 form: mainForm
a multi selection list box (Regions in it)
a button: filterBut

i would like to select fiew regions and by pressing a button (filterBut) filter all companys in selected regions.

i've tried to use this:
Private Sub filterBut_Click()
Forms![mainForm].Form.Filter = "region=" & Me. ????
Forms![mainForm].Form.FilterOn = True
End Sub

but i have no idea what to put after Me. ?

all i found is this:
list box filter to report

but that gives a string and it's not what i need

Any ideas or hints how to make it work?

Thanks..

Mateusz Zawada
 
I don't use filters prefering SQL instead, however, I think your approach is flawed.

To filter move through your list box first, finding all selected regions and add them to a string. Use this string as your filter source and I imagine you will be fine.
 
hello..
thanks for you comment.

that's what i was trying to do useing this code:

Private Function GetCriteria() As String
Dim filterCriteria As String
Dim VarItm As Variant
For Each VarItm In ListFilter.ItemsSelected
filterCriteria = filterCriteria & "[region] = " & regionList.Column(0, VarItm) & " OR "
Next
If filterCriteria <> "" Then
filterCriteria = Left(filterCriteria, Len(filterCriteria) - 4)
Else
filterCriteria = "True"
End If
GetCriteria = filterCriteria
End Function

this function should give a string from regionList lisbox..
as far as i remember there was a mistake somewhere.. but even if it would work i have no idea how to connect string to filter button.
 

Users who are viewing this thread

Back
Top Bottom