A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

SQL syntax help please



 
 
Thread Tools Display Modes
  #1  
Old March 1st, 2010, 11:45 AM posted to microsoft.public.access
Sue[_11_]
external usenet poster
 
Posts: 6
Default SQL syntax help please

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...


  #2  
Old March 1st, 2010, 12:16 PM posted to microsoft.public.access
Stefan Hoffmann
external usenet poster
 
Posts: 991
Default SQL syntax help please

hi Sue,

On 01.03.2010 12:45, Sue wrote:
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 --
  #3  
Old March 1st, 2010, 12:28 PM posted to microsoft.public.access
MikeR
external usenet poster
 
Posts: 147
Default SQL syntax help please

Sue wrote:
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
  #4  
Old March 1st, 2010, 01:58 PM posted to microsoft.public.access
Sue[_11_]
external usenet poster
 
Posts: 6
Default SQL syntax help please

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" wrote in message
...
hi Sue,

On 01.03.2010 12:45, Sue wrote:
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 --



  #5  
Old March 1st, 2010, 02:10 PM posted to microsoft.public.access
Stefan Hoffmann
external usenet poster
 
Posts: 991
Default SQL syntax help please

hi Sue,

On 01.03.2010 14:58, Sue wrote:
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 --
  #6  
Old March 13th, 2010, 05:58 PM posted to microsoft.public.access
De Jager
external usenet poster
 
Posts: 393
Default SQL syntax help please


"Sue" wrote in message
...
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...


  #7  
Old March 17th, 2010, 01:49 PM posted to microsoft.public.access
joelgeraldine
external usenet poster
 
Posts: 201
Default SQL syntax help please

kjkjkjk

"Sue" a écrit dans le message de groupe de
discussion : ...
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...

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:14 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.