?
Solved

Syntax error (missing operator) SQL

Posted on 2010-11-17
4
Medium Priority
?
297 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 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

Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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…
Suggested Courses

770 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