Help with update query syntax

hardrock

Registered User.
Local time
Today, 23:05
Joined
Apr 5, 2007
Messages
166
Hi Guys

I'm trying to get this Update query to work, but it fails with the addition of the second parameter in the 'Where' clause

DoCmd.RunSQL "UPDATE Tb_DistinctReceipts SET Tb_DistinctReceipts.TotalQTY = '" & POsum & "'WHERE PurchaseOrder = " & PO & " AND Where LineItem = " & Line & ";"

Could someone please help me with the syntax? Many thanks
 
Last edited:
You don't repeat the word WHERE, and I added a space before the remaining WHERE:

DoCmd.RunSQL "UPDATE Tb_DistinctReceipts SET Tb_DistinctReceipts.TotalQTY = '" & POsum & "' WHERE PurchaseOrder = " & PO & " AND LineItem = " & Line & ";"

That should work IF TotalQTY is a text value, which seems odd, and both PurchaseOrder and LineItem are numeric values. Also, I would use CurrentDb.Execute rather than DoCmd.RunSQL. It's more efficient and doesn't throw the warnings.
 
Many Thanks PBaldy. Works a treat now!
 

Users who are viewing this thread

Back
Top Bottom