Solved Select query on form, update one row at a time? (1 Viewer)

A1ex037

Registered User.
Local time
Today, 15:32
Joined
Feb 10, 2018
Messages
50
I have a select query that shows all orders placed during the day. The status of the order is "ordered". The query works fine, and it is placed on a form. What I have to do is to change the status of each order separately when the package is sent.



I have created a column on query that displays "mark as sent", changed it in form options to always display as hyperlink. I have tried to make onClick event, but I am missing something in WHERE clause. I have tried with


Code:
CurrentDb.Execute "UPDATE tblSales SET Status = 'Sent' WHERE ID = tblSales.ID"
but it changes the order status of the entire Sales table. Not sure if I can place condition in WHERE clause like this at all.



Any help is appreciated.
 

June7

AWF VIP
Local time
Today, 06:32
Joined
Mar 9, 2014
Messages
5,423
Concatenate variable:

CurrentDb.Execute "UPDATE tblSales SET Status = 'Sent' WHERE ID = " & Me!ID

But if Status field is in the form's RecordSource, could simply be:

Me!Status = "Sent"
 

A1ex037

Registered User.
Local time
Today, 15:32
Joined
Feb 10, 2018
Messages
50
Thank you, it worked. Could you please explain (if I am not asking too much), what is wrong with my line?
 

June7

AWF VIP
Local time
Today, 06:32
Joined
Mar 9, 2014
Messages
5,423
Reference to control or field of each record is referencing a variable. Variables must be concatenated otherwise it is just literal text within quote marks instead of passing the value the variable holds.
 

Users who are viewing this thread

Top Bottom