Exclude a record that contains ABC

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?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dale FyeOwner, Dev-Soln LLCCommented:
strSQL = strSQL & "WHERE (tblEstimateSamples.EstimateID = " & lngEstimateID) _
             & " AND NOT (tbSamplesTypesLU.Description Like '*ABC*'")
SteveL13Author Commented:
Am getting "expected end of statement"
Bill PrewIT / Software Engineering ConsultantCommented:
Try this adjustment.

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

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SteveL13Author Commented:
I actually got it with:

strSQL = strSQL & "WHERE tblEstimateSamples.EstimateID = " & lngEstimateID & " AND NOT (tbSamplesTypesLU.Description) Like '*ABC*'"
Dale FyeOwner, Dev-Soln LLCCommented:
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*')"
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.