Problem with runSQL Update

  • Thread starter Thread starter James Frater
  • Start date Start date
J

James Frater

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
 
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 & "'"
 
You need something like:
SQL = "UPDATE Tbl_Booking " & _
"SET Tbl_Booking.PartDelete = False " & _
"WHERE Tbl_Booking.Ev_ID = " & ev_id

ev_id is a variable so has to be concatrenated onto your SQL command, you
will probably have to qualify it with the name of the form and subform.

-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 
Back
Top