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 ...
0

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

0
Amour22015Author Commented:
for yan

Thank you,

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

Thank you
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

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

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

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.