null string

S

Sirocco

This isn't so much a question as an example of how insanely ridiculous SQL
syntax can be.
I pulled my hair out trying to solve this one, even with some sample code
that contains the proper syntax. In the following SQL, why doesn't it work
without the empty string just before the first line continuation characters?
If the idea is to generate an actual SQL string, including spaces between
key words, why not just put an extra space before the WHERE of the second
line, and why isn't an extra empty string also necessary before the AND of
the last line?

strSQL = "UPDATE table SET StatusCode =" & Me![Combo10] & " " & _
"WHERE table.CaseCode = " & Me![CaseCode] & _
"AND table.ActualDate = #" & Me![BeginDate] & "#"

Thanks in advance.
 
R

Ron Weiner

If it were me I'd code it like:

strSQL = "UPDATE table SET StatusCode =" & Me![Combo10] & " " _
& "WHERE (table.CaseCode = " & Me![CaseCode] & ") " _
& "AND (table.ActualDate = #" & Me![BeginDate] & "#);"

I LIKE to have the begining of the continuation line start with the
Amperstand.

Ron W
 
S

Sirocco

Well, thanks for raising more questions. In particular, why the semicolon
at the end? (Note that the code I included in my initial questions works,
in my existing mdb file.) Also, why put each WHERE clause in parens?
Are these extras necessary with a SQL back end?

Actually, my initial question wasn't answered. Any comments?


Thanks again!


Ron Weiner said:
If it were me I'd code it like:

strSQL = "UPDATE table SET StatusCode =" & Me![Combo10] & " " _
& "WHERE (table.CaseCode = " & Me![CaseCode] & ") " _
& "AND (table.ActualDate = #" & Me![BeginDate] & "#);"

I LIKE to have the begining of the continuation line start with the
Amperstand.

Ron W
Sirocco said:
This isn't so much a question as an example of how insanely ridiculous SQL
syntax can be.
I pulled my hair out trying to solve this one, even with some sample code
that contains the proper syntax. In the following SQL, why doesn't it work
without the empty string just before the first line continuation characters?
If the idea is to generate an actual SQL string, including spaces between
key words, why not just put an extra space before the WHERE of the second
line, and why isn't an extra empty string also necessary before the AND of
the last line?

strSQL = "UPDATE table SET StatusCode =" & Me![Combo10] & " " & _
"WHERE table.CaseCode = " & Me![CaseCode] & _
"AND table.ActualDate = #" & Me![BeginDate] & "#"

Thanks in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top