View Full Version : SQL Statement Quotation Marks


lukasgill
11-04-2007, 01:40 AM
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?

gemma-the-husky
11-04-2007, 08:29 AM
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

boblarson
11-04-2007, 09:14 AM
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).