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
 
Back
Top