There should be no problem with AS within the string.
To embed quote marks in the string, double them up, e.g.:
Dim strSql As String
strSQL = "SELECT [2003] AS Actual FROM MyTable WHERE ([MyCategoryField]
Between ""a"" And ""ezzz"");"
CurrentDb().QueryDefs("MyQuery").SQL = strSQL
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Hannes S" <hs******@gmx.at> wrote in message
news:40**************@news.utanet.at...
Hi Experts,
I have a general question.
I want to create a string (in VBA) for the sql property of a DefQuery
Object. But I don't know how to include expressions like the key word
--> AS <-- and --> " " <--.
I tried it with --> ' ' <--, but without success.
Examples which I would like to integrate:
string = "select [2003] AS ACTUAL, [2002] AS LAST_YEAR ...
.... between "aa" and "ee" ........
Thanks in advance for your help.
Kind regards,
Hannes