Help With Syntax

  • Thread starter Thread starter Bongard
  • Start date Start date
B

Bongard

Hi, I am trying to pass the SQL from a query in VBA as a string so
that I can pass variables as paramaters in different functions. I am
having trouble getting my SQL to format correctly though. Everytime I
try running the query in VB with the Docmd.runSQL I get "Syntax error
in query expression." Here is my SQL

Dim myL As String
myL = Chr$(34)

MySQLString = "SELECT IIf([testemail]=Yes, Concatenate(myL SELECT
EmailAddress FROM Z_EmailNotifications WHERE TestEmail=MyL & myL Yes
MyL)) AS FinalAddress, Z_EmailNotifications.TestEmail " & _
"FROM Z_EmailNotifications " & _
"GROUP BY IIf([testemail]=Yes,Concatenate(my L
SELECT EmailAddress FROM Z_EmailNotifications WHERE TestEmail=myL &
myL Yes myL)), Z_EmailNotifications.TestEmail " & _
"HAVING (((TestEmail)=Yes));"

Can anyone help me to get that query to work in VB? I would greatly
appreciate it.

Thanks alot!
Brian
 
hi,
try to copy resulted SQL and paste it in new query SQL window and run it,
then you can better see what is wrong. In general - I think you have to make
myL either single quote or """" (four double quotes)

--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top