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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

updating stock levels 1

Status
Not open for further replies.

mudstuffin

Technical User
Sep 7, 2001
92
GB

Hello.

I am trying to figure out how the stock level in the products table can be updated when a quantity is entered for a product in the order form. I am playing around with the Northwind database trying to figure it out. Can someone give some code to do this using the details below...?

The details are...

Table containing product details:- Products
contains fields:- ProductId,ProductName,UnitsInStock

The order form:- OrderForm
textboxes:- ProductID,ProductName,QtyOrdered.

Or am I going about this the wrong way...?

Thanks,


mudstuffin.
 
You're on the right track.
DAO version would go something like this:

dim db as DAO.Database
dim strSql as String
dim qdf as QueryDef
dim QtyOrdered as long
dim ProductID as long

ProductID = me.ProductID 'the value on the order form
QtyOrdered = me.QtyOrdered 'the quantity on the order form
strSql="UPDATE Products SET UnitsInStock = (UnitsInStock - " & QtyOrdered & ") WHERE ProductID=" _
& ProductID

set db=currentdb()
set qdf = db.CreateQueryDef("",strSql)
qdf.execute
set qdf=nothing
set db=nothing

 
Thanks for that Veep.

Just what I was looking for and does the job spot-on.

Regards,


mudstuffin.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top