Solved

Syntax error (missing operator) SQL

Posted on 2010-11-17
4
292 Views
Last Modified: 2012-05-10
Experts,

I'm trying run the SQL below in the on open event, and set it equal to a graphs's row source. I copied and pasted it from a query that works, but I'm getting the attached syntax error (missing operator)  when I try to run it from the on open event.

Thanks,
James
strSQL2 = "SELECT (Format([MDate],'mmm'' '''yy')) AS Expr1, Avg(qryMAIN_Patient_WtHtBMI_calc3.BMI4A_P) AS AvgOfBMI4A_P " & _
"FROM qryMAIN_Patient_WtHtBMI_calc3 " & _
"GROUP BY(Format([MDate], 'mmm'' '''yy')), (Year([MDate]) * 12 + Month([MDate]) - 1) " & _
"ORDER BY (Year([MDate])*12+Month([MDate])-1)"

Open in new window

error.PNG
0
Comment
Question by:jdallain
  • 2
4 Comments
 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 34155475
Try this code

strSQL2 = "SELECT (Format([MDate],'''mmm''' '''yy''')) AS Expr1, Avg(qryMAIN_Patient_WtHtBMI_calc3.BMI4A_P) AS AvgOfBMI4A_P " & _
"FROM qryMAIN_Patient_WtHtBMI_calc3 " & _
"GROUP BY(Format([MDate], '''mmm''' '''yy''')), (Year([MDate]) * 12 + Month([MDate]) - 1) " & _
"ORDER BY (Year([MDate])*12+Month([MDate])-1)"

Open in new window


Need more apostrophe

Raj
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 34155484
what about this:

strSQL2 = "SELECT (Format([MDate],'mmm yy')) AS Expr1
, Avg(qryMAIN_Patient_WtHtBMI_calc3.BMI4A_P) AS AvgOfBMI4A_P " & _
"FROM qryMAIN_Patient_WtHtBMI_calc3 " & _
"GROUP BY(Format([MDate], 'mmm yy')), (Year([MDate]) * 12 + Month([MDate]) - 1) " & _
"ORDER BY (Year([MDate])*12+Month([MDate])-1)"

Open in new window

0
 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 34155513
Oh! I think, angelIII provided right solution

Raj
0
 

Author Closing Comment

by:jdallain
ID: 34155565
Thanks  a lot fellows!

James
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question