Can I add an IF to a WHERE statement in a Link Query. (1 Viewer)

jeff3457

Registered User.
Local time
Today, 10:11
Joined
Oct 30, 2019
Messages
25
Hello,

I am working within a Link Query and have several filters I've put in.

"WHERE ([Contract #] NOT LIKE "") AND [Acct Code] NOT LIKE '72801011*' AND ([Pay Status] NOT LIKE 'L')"

Now I would like to add another criteria essentially saying, "exclude if Acct begins with 1234 and Contract begins with 9876". But only if they both appear in one line item.
 

June7

AWF VIP
Local time
Today, 06:11
Joined
Mar 9, 2014
Messages
5,423
Do you allow empty strings in text fields? - I NEVER do.

Advise not to use spaces nor punctuation/special characters in naming convention.

Yes, IIf() expressions are possible in WHERE clause but possibly not what you want in this case.

AND NOT ([Acct Code] LIKE "1234*" AND [Contract #] LIKE "9876*")
 

jeff3457

Registered User.
Local time
Today, 10:11
Joined
Oct 30, 2019
Messages
25
Do you allow empty strings in text fields? - I NEVER do.

Advise not to use spaces nor punctuation/special characters in naming convention.

Yes, IIf() expressions are possible in WHERE clause but possibly not what you want in this case.

AND NOT ([Acct Code] LIKE "1234*" AND [Contract #] LIKE "9876*")

Thank you! That is exactly what I needed. I was placing the NOT in the wrong place which was breaking it.

I do plan to fix the spaces. I uploaded an external excel file into my base tables and they all came with spaces. Going to go back and update at some point. I've learned the hard way they don't play well with others.
 

Users who are viewing this thread

Top Bottom