Re: Problem with runSQL Update

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



On Thu, 15 Oct 2009 08:19:27 -0700, James Frater wrote:

Hello All,

On the Click() event of a button I would like to run the update query:

SQL = "UPDATE Tbl_Booking " & _
"SET Tbl_Booking.PartDelete = False " & _
"WHERE Tbl_Booking.Ev_ID = ev_id"

docmd.runSQL SQL

However it fails to find or recognise ev_id, any thoughts on where I'm going
wrong? I'm guessing it's something blindingly obvious!

If it helps the button and the value ev_id are on a continuous subform
called "frm_EventRestore".

Many thanks

James

As written, your Where clause is looking for a literal ev_id as it's
critieria, not the value that ev_id contains.

The Where clause ev_id value must be concatenated into the expression.

Assuming ev_id is a Number datatype:
"WHERE Tbl_Booking.Ev_ID = " & ev_id


If in fact it is a Text datatype then use:
"WHERE Tbl_Booking.Ev_ID = '" & ev_id & "'"
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
.



Relevant Pages

  • Re: Select Case Statement
    ... it returns a value of one datatype. ... SQL-92 stole the idea and the ... its THEN clause. ... WHEN NULL THEN 'no bar' ...
    (microsoft.public.sqlserver.programming)
  • Re: CASE and UPDATE
    ... it returns a value of one datatype. ... SQL-92 stole the idea and the ... its THEN clause. ... WHEN NULL THEN 'no bar' ...
    (microsoft.public.sqlserver.programming)
  • Re: Using CASE statement
    ... it returns a value of one datatype. ... SQL-92 stole the idea and the ... its THEN clause. ... WHEN NULL THEN 'no bar' ...
    (microsoft.public.sqlserver.programming)
  • Re: using "case" in where clause
    ... it returns a value of one datatype. ... SQL-92 stole the idea and the ... its THEN clause. ... WHEN NULL THEN 'no bar' ...
    (microsoft.public.sqlserver.programming)
  • Re: select
    ... it returns a value of one datatype. ... SQL-92 stole the idea and the ... its THEN clause. ... WHEN NULL THEN 'no bar' ...
    (microsoft.public.sqlserver.programming)