Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Subtracting using form data

Status
Not open for further replies.

softbrix2

Technical User
Feb 28, 2005
17
US
DoCmd.RunSQL ("UPDATE products SET products.Stock =(products.Stock -1 WHERE products.ProductID=17") that works fine.
Code below Don't Work.
-----------------don't work-----------------------
DoCmd.RunSQL ("UPDATE products SET products.Stock = (products.Stock - [Forms]![Orders]![Order Details Subform]![Quantity] WHERE products.ProductID=[Forms]![Orders]![Order Details Subform]![productid]")

this is my sql query. it will work perfectly if I manually put data in the varibles but If I reference the form data it doen's work. if I msgbox out the form data it shows fine. but once I put the form variable back in the sql stings they are blank. how can I get the value of the form data in the sql string.

 
You may try this:
DoCmd.RunSQL "UPDATE products SET Stock=Stock - " & Forms!Orders![Order Details Subform].Form!Quantity & " WHERE ProductID=" & Forms!Orders![Order Details Subform].Form!productid

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
thanks it work perfectly. I'll post another question in another tread
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top