Problem with runSQL Update

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
 
F

fredg

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 & "'"
 
D

Dorian

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

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