Trouble with a filter sequence (1 Viewer)

Trocergian

Registered User.
Local time
Yesterday, 19:38
Joined
Apr 6, 2009
Messages
16
I'm trying to get this filter to work with multiple ANDS/ORS and having trouble.
The line is:

Code:
 Me.Filter = "([CustID] = 1030 OR [CustID] = 1044 OR [CustID] = 1051 OR [CustID] = 1055 AND [BoLChk] <> 'X' OR [INVChk] <> 'X')"

The filters on either side of the AND work independently, but combining them with the AND allows any CUSTID to display.

What do I have wrong or is what I'm trying to accomplish not possible this way?
 

Minty

AWF VIP
Local time
Today, 01:38
Joined
Jul 26, 2013
Messages
10,374
Try the following I have assumed the addition of the brackets to force the logic is correct.

Code:
 Me.Filter = "([CustID] In (1030 ,1044 ,1051 ,1055))  AND ([BoLChk] <> 'X' OR [INVChk] <> 'X')"
 

Trocergian

Registered User.
Local time
Yesterday, 19:38
Joined
Apr 6, 2009
Messages
16
Try the following I have assumed the addition of the brackets to force the logic is correct.

Code:
 Me.Filter = "([CustID] In (1030 ,1044 ,1051 ,1055))  AND ([BoLChk] <> 'X' OR [INVChk] <> 'X')"

Bingo! Thank you so much. I'd been struggling with that for 2 hours trying different permutations. The solution not only works but is much more elegant.
 

Minty

AWF VIP
Local time
Today, 01:38
Joined
Jul 26, 2013
Messages
10,374
Glad it is sorted. Access frequently adds millions of brackets to where clauses in SQL queries, that are mostly unnecessary, however in your case you need the to make it perform the criteria in the right order by using parentheses.

I still forget about using the In(...) syntax quite often, and I've been doing this for long enough not to forget.
 

Users who are viewing this thread

Top Bottom