Exclude a record that contains ABC

SteveL13
SteveL13 used Ask the Experts™
on
Am trying to exclude a record that contains ABC in the description.  Here is my code which isn't working:

strSQL = strSQL & "WHERE tblEstimateSamples.EstimateID = " & lngEstimateID & " AND tbSamplesTypesLU.Description <> 'ABC'"

Can someone help?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Dale FyeOwner, Dev-Soln LLC
Most Valuable Expert 2014
Top Expert 2010

Commented:
strSQL = strSQL & "WHERE (tblEstimateSamples.EstimateID = " & lngEstimateID) _
             & " AND NOT (tbSamplesTypesLU.Description Like '*ABC*'")

Author

Commented:
Am getting "expected end of statement"
IT / Software Engineering Consultant
Top Expert 2016
Commented:
Try this adjustment.

strSQL = strSQL & "WHERE (tblEstimateSamples.EstimateID = " & lngEstimateID & ")" _
             & " AND NOT (tbSamplesTypesLU.Description Like '*ABC*')"

Open in new window


»bp

Author

Commented:
I actually got it with:

strSQL = strSQL & "WHERE tblEstimateSamples.EstimateID = " & lngEstimateID & " AND NOT (tbSamplesTypesLU.Description) Like '*ABC*'"
Dale FyeOwner, Dev-Soln LLC
Most Valuable Expert 2014
Top Expert 2010
Commented:
If you are just going to wrap the field in parentheses, you don't need them at all.

I would use the modification of my original post recommended by Bill.  This will ensure that the NOT argument addresses the entire expression:

(tbSamplesTypesLU.Description Like '*ABC*')"

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial