Help with like statement in SQL string using VBA

I am trying to get a like statement to work in my code. Can anyone help with it? strCustomer is a string variable being passed.

If rs!strCustomer = like ('%'" & strCustomer & "'%') And rs!numDetail = (numDetail * -1) Then
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

If you are using ACE or Jet ("Access") as the BE, then you need to use the Access wild card characters.  Use * rather than % as the generic string match.
smm6809Author Commented:
I am using Access, ado. I can change the wildcard, however, the syntax itself is incorrect.
Anthony BerenguelCommented:
If rs!strCustomer like "*" & strCustomer & "*" And rs!numDetail = (numDetail * -1) Then

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
Active Protection takes the fight to cryptojacking

While there were several headline-grabbing ransomware attacks during in 2017, another big threat started appearing at the same time that didn’t get the same coverage – illicit cryptomining.

Rey Obrero (Capricorn1)Commented:
you have to remove the "=" equal sign, and just use "like"

If rs!strCustomer  like '%'" & strCustomer & "'%' And rs!numDetail = (numDetail * -1) Then
Rey Obrero (Capricorn1)Commented:
sorry, it shouldbe

If rs!strCustomer Like "%" & strCustomer & "%" And rs!numDetail = (numDetail * -1) Then
Rey Obrero (Capricorn1)Commented:
oops, sorry Anthony, did not see your post
With rs
     If !strCustomer like "*" & strCustomer & "*" And !numDetail = (numDetail * -1) Then
           'whatever you need
           'what happens when not true
    End if
End With

But what are strCustomer and numDetail?
Variables you have created?
Controls on a form or report?

And this is a curious construction
numDetail * -1

Can you provide more detail about what you are doing?
Dale FyeOwner, Developing Solutions LLCCommented:
Personally, for this type of thing I prefer to use the Instr() function.
    If instr(strCustomer, rs!strCustomer) > 0 AND rs!numDetail = (numDetail * -1) Then
           'whatever you need
           'what happens when not true
    End if

Open in new window

You might need to change the order of those parameters inside the instr() function.
smm6809Author Commented:
Thank you.
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.