Access 2007 sSQL string

Thank you all for helping me!

I have this sSQL string that has an error:

 
sSQL = "Select * from OCATable where DONFrstName = '" & TxtFrstName & "' And DONLstName = '" & TxtLstName & "' AND  DONPass = '" & Me.txtPassword & "' _
 OR OCAFrstName = '" & TxtFrstName & "' And OCALstName = '" & TxtLstName & "' AND  OCAPass ='" & Me.txtPassword & "' _
 OR CSMFrstName = '" & TxtFrstName & "' And CSMLstName = '" & TxtLstName & "' AND  CSMPass ='" & Me.txtPassword & "' _
 OR RSMFrstName = '" & TxtFrstName & "' And RSMLstName = '" & TxtLstName & "' AND  RSMPass ='" & Me.txtPassword & "'"

Open in new window


the error:
Compile error:
Expected: expression

And stops at:
OR OCAFrstName = '" & TxtFrstName

Thank you for helping me!
Amour22015Asked:
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.

for_yanCommented:
maybe you should not break the line within the quote:


AND  DONPass = '" & Me.txtPassword & _
 "' Or OCAFirstName ...

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
for_yanCommented:

something like that:

sSQL = "Select * from OCATable where DONFrstName = '" & TxtFrstName & "' And DONLstName = '" & TxtLstName & "' AND  DONPass = '" -
 & Me.txtPassword &  "' OR OCAFrstName = '" & TxtFrstName & "' And OCALstName = '" & TxtLstName & "' AND  OCAPass ='" & Me.txtPassword & _
"' OR CSMFrstName = '" & TxtFrstName & "' And CSMLstName = '" & TxtLstName & "' AND  CSMPass ='" & Me.txtPassword & _
 "'  OR RSMFrstName = '" & TxtFrstName & "' And RSMLstName = '" & TxtLstName & "' AND  RSMPass ='" & Me.txtPassword & "'"

Open in new window

Amour22015Author Commented:
for yan

Thank you,

I tryed your code:
still giving me a red highlighted error.

Thank you
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

for_yanCommented:
Still reports error in the same place?
for_yanCommented:

like it was:
>And stops at:
>OR OCAFrstName = '" & TxtFrstName
Amour22015Author Commented:
Great I just did not break line at all and it stopped giving the red compile error.  Thank you
for_yanCommented:
Great!
You are always welcome.
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.