On Aug 16, 12:14 pm, "bhipwell via AccessMonster.com" <u30281@uwe>
wrote:
Quote:
I went back to a recently saved filed and worked through the error I was
having. The error has since disappeared, however I need to address the
structure of my queries. I think I may take your approach when I begin
cleaning them up.
>
Quick question, I am just fine at writing VBA code, but a little weak in SQL.
I can struggle through it for awhile until I get the hang of it. Any advise
to get a cliff notes version of writing SQL?
>
B
>
--
Message posted via AccessMonster.comhttp://www.accessmonster.com/Uwe/Forums.aspx/databases-ms-access/2007...
I'm sure there are tons of guides and quick learning books available
for ramping up SQL skills. But I think the best way to learn is to
just do it. To that end Bill's suggestion is probably best. Just look
at the SQL your query designer builds, it helps to indent it and
separate out the lines in a text editor to see what you are doing,
then just paste it into VBA.
You probably know all this from your VBA experience but I think it
bears repeating.
If the queries are short enough then just put it all on one line:
currentdb.execute "update mybesttable set status = 1"
if the query is longer you need to keep it all together by adding " &
_ " at the end of each line and making sure each portion of the
statement is enclosed in quotes. The funky quotes come into play if
you have text references in your query criteria because text
references are surrounded by quotes. When you run a query in VBA its
like another level of processing so you need to write the query to
accommodate that. A single quote must be written as a double quote for
it to be read as a single quote:
currentdb.execute "update mybesttable " & _
"set status = 2 " & _
"where first_name = ""Bill"" " & _
"and status = 1"