SQL Statement Quotation Marks

lukasgill

Registered User.
Local time
Yesterday, 20:49
Joined
Sep 4, 2007
Messages
14
I have a statement which is driving me nuts...i'm a beginner with using SQL:

Private Sub Command45_Click()

Me.Graph0.RowSource = "SELECT (Format([Date],""" """mmm""" ''yy')) AS Expr1 FROM Chart_Unsafe_Daily GROUP BY (Format([Date],'mmm'' '''yy")), (Year([Date])*12+Month([Date])-1);

End Sub

The statement is RED for an error, i'm sure it is because the quotation marks within the statement are incorrect.

Can anybody help me out?
 
the format dates should look like

format mydate,("ddd mmm yyyy")

with whatever is appropriate for the display you want in the quote marks

it is recommended that you dont use the field name [date] as date is a reserved word - this mat cause ambiguity at best and lead to programming errors at worst
 
And, instead of having to embed double quotes, single quotes will work for SQL. (for any place where you would normally use double quotes EXCEPT the ones at the very beginning and very end of the SQL string).
 
Last edited:

Users who are viewing this thread

Back
Top Bottom