Update query doesn't select 1 record

WalterInOz

Registered User.
Local time
Today, 17:21
Joined
Apr 11, 2006
Messages
93
Upon closing my frmInventory the amount stock of stock is checked against a minimal stock value. If the stock amount is below a set minimal value a subsequent form is opened telling you that stock is low and an email message is generated to notify a manager. I have a checkbox on that form which is set to "True" upon close using an update query. The checkbox is there to give users the option to either send or not send a reminder message that stock is low when a message has already been sent earlier.

The problem is that using that update query ALL records are set to "sent=true" and not just the 1 record I intend.

This is my code in the "on close" event:

DoCmd.OpenQuery "qryUpdateEmailMinimal_True

and here's the SQL:

UPDATE tblInventory SET tblInventory.emailSentMinimal = True;


I assume what is missing is a reference to an inventoryID number. How do I do that?
 
Something like...
WalterInOz said:
UPDATE tblInventory SET tblInventory.emailSentMinimal = True WHERE inventoryID = Forms!yourformname!yourfieldname;
 
Thanks Adeptus.
You were very close.

with

Forms!frmEmailMinimal!InventoryID

an error message popped up in a messagebox:

Cannot find Forms!frmEmailMinimal!InventoryID

Replacing the ! with a. (giving Forms.frmEmailMinimal.InventoryID) did the trick! All now works as it should.

Thanks for your tip.
 
Why use an update query? Set the value using the relevant form event.
 

Users who are viewing this thread

Back
Top Bottom