Filter question!!

Stefanw

Registered User.
Local time
Today, 21:56
Joined
Jan 15, 2007
Messages
20
Hi,

i would be very happy, if someone could give me some advise, because I am stuck for a while... :confused:

I want to filter my results into a report. I have some listboxes in a form, one of them is strContractcity. This one is to be copied to strContactcity2 and strContractcity3.

(For ex. strContractcity = "New York", then strContractcity2 and strContractcity3 will be automatically "New York". But I want them filter to look for
strContractcity = "New York" OR
strContractcity2 = "New York" OR
strContractcity3 = "New York"

But like now, all the strContractcities works, but the rest (cities, zone_name, zone_letter, Contacttype, name) doesn't work.

Thanks a lot!!

Stefan



Here is a piece of the code:

---------------

For Each varItem In Me.lstcontractcity.ItemsSelected
strContractcity = strContractcity & ",'" & Me.lstcontractcity.ItemData(varItem) _
& "'"
Next varItem
If Len(strContractcity) = 0 Then
strContractcity = "Like '*'"
strContractcity2 = "Like '*'"
strContractcity3 = "Like '*'"
Else
strContractcity = Right(strContractcity, Len(strContractcity) - 1)
strContractcity = "IN(" & strContractcity & ")"
strContractcity2 = strContractcity
strContractcity3 = strContractcity

End If


---------------
strFilter = ("[cities.city] " & strCity & _
" AND [client] " & strName & _
" AND [zone_name] " & strZone & _
" AND [zone_letter] " & strCode & _
" AND [ContactType] " & strCategory & _
" AND [name] " & strManager)
strFilter = (" [contractcity.city] " & strContractcity & _
" OR [contractcity2.city] " & strContractcity2 & _
" OR [contractcity3.city] " & strContractcity3)

------------
 
You need to bracket the ORs like so:

strFilter = "( [contractcity.city] " & strContractcity & _
" OR [contractcity2.city] " & strContractcity2 & _
" OR [contractcity3.city] " & strContractcity3 & ")"
 
hi mailman,
thanks for your fast respond.

currently i have the code like this:

strFilter = "[cities.city] " & strCity & _
" AND [client] " & strName & _
" AND [zone_name] " & strZone & _
" AND [zone_letter] " & strCode & _
" AND [ContactType] " & strCategory & _
" AND [name] " & strManager
strFilter = "( [contractcity.city] " & strContractcity & _
" OR [contractcity2.city] " & strContractcity2 & _
" OR [contractcity3.city] " & strContractcity3 & ")"



All the contractcities are filtered perfect, the only thing, that the rest, (name, client, Contacttype, etc) aren't being filtered.
Plz.... help!!
 
Solved, I forgot to put an "AND"...

thankx a lot, mailman!!!
-----

strFilter = "[cities.city] " & strCity & _
" AND [client] " & strName & _
" AND [zone_name] " & strZone & _
" AND [zone_letter] " & strCode & _
" AND [ContactType] " & strCategory & _
" AND [name] " & strManager & _
" AND( [contractcity.city] " & strContractcity & _
" OR [contractcity2.city] " & strContractcity2 & _
" OR [contractcity3.city] " & strContractcity3 & ")"
 
I forgot to add the and as well.... but yeah that should be it!

Good for you that you solved it! :D
 

Users who are viewing this thread

Back
Top Bottom