SQL syntax help please

S

Sue

Hi all

I had an update sql statement working setting a value to true (boolean
field) on a set condition, but I am now trying to update a 2nd field also
which is text type and I can't seem to get the syntax right. I get 'expected
end of statement' message. Code is:

strSQL = "UPDATE [qry Resource Planning VVs] " & _
"SET [Selected] = True & _
"[Activity] = '"VV"', " & _
"WHERE Territory_Code = " & """" & txtTerritory & """"

Can anyone please help correct this? Thanks...
 
S

Stefan Hoffmann

hi Sue,

I get 'expected end of statement' message. Code is:

strSQL = "UPDATE [qry Resource Planning VVs] "& _
"SET [Selected] = True& _
"[Activity] = '"VV"', "& _
"WHERE Territory_Code = "& """"& txtTerritory& """"
There is a comma missing and the quotation marks are also wrong:

strSQL = _
"UPDATE [qry Resource Planning VVs] " & _
"SET [Selected] = True, " & _
"[Activity] = 'VV' " & _
"WHERE [Territory_Code] = '" & Replace(txtTerritory, "'", "''") & "'"


mfG
--> stefan <--
 
M

MikeR

Sue said:
Hi all

I had an update sql statement working setting a value to true (boolean
field) on a set condition, but I am now trying to update a 2nd field also
which is text type and I can't seem to get the syntax right. I get 'expected
end of statement' message. Code is:

strSQL = "UPDATE [qry Resource Planning VVs] " & _
"SET [Selected] = True & _
"[Activity] = '"VV"', " & _
"WHERE Territory_Code = " & """" & txtTerritory & """"

Can anyone please help correct this? Thanks...
Maybe "SET [Selected] = True " & _ (missing closing quote).

Mike
 
S

Sue

Thanks Stefan that sorted it :). I changed the quotes and added the comma.
I left the where clause alone though as this was working ok before. Thanks
again for the help!!


Stefan Hoffmann said:
hi Sue,

I get 'expected end of statement' message. Code is:

strSQL = "UPDATE [qry Resource Planning VVs] "& _
"SET [Selected] = True& _
"[Activity] = '"VV"', "& _
"WHERE Territory_Code = "& """"& txtTerritory&
""""
There is a comma missing and the quotation marks are also wrong:

strSQL = _
"UPDATE [qry Resource Planning VVs] " & _
"SET [Selected] = True, " & _
"[Activity] = 'VV' " & _
"WHERE [Territory_Code] = '" & Replace(txtTerritory, "'", "''") & "'"


mfG
--> stefan <--
 
S

Stefan Hoffmann

hi Sue,

Thanks Stefan that sorted it :). I changed the quotes and added the comma.
I left the where clause alone though as this was working ok before. Thanks
again for the help!!
Just enter a " in your txtTerritory before executing your code. Test it...

mfG
--> stefan <--
 
D

De Jager

Sue said:
Hi all

I had an update sql statement working setting a value to true (boolean
field) on a set condition, but I am now trying to update a 2nd field also
which is text type and I can't seem to get the syntax right. I get
'expected end of statement' message. Code is:

strSQL = "UPDATE [qry Resource Planning VVs] " & _
"SET [Selected] = True & _
"[Activity] = '"VV"', " & _
"WHERE Territory_Code = " & """" & txtTerritory & """"

Can anyone please help correct this? Thanks...
 

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