Results 1 to 2 of 2

Thread: Subtracting from Quantity in Stock

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2004
    Location
    Canada
    Posts
    5

    Question Subtracting from Quantity in Stock

    Hello all,

    I am simply trying to reduce the quantity in stock by the number ordered.

    Code:
    set rsUpdateQuantity = Server.CreateObject("ADODB.Recordset")
    	rsUpdateQuantity.Open "SELECT * FROM products WHERE productNumber = " _ 
    & intStock, Conn, adOpenStatic, adLockOptimistic, _
    adCmdText
    			
    	if rsUpdateQuantity("numInStock") > 1 then
    	intNumInStock = rsUpdateQuantity("numInStock")
    		if intQuant < intNumInStock then
    			rsUpdateQuantity("numInStock") = intNumInStock - intQuant
    		end if
    	else
    		rsUpdateQuantity.DELETE
    	end if
    				
    	rsUpdateQuantity.Update
    	rsUpdateQuantity.Close
    I am a newbie to VBScript so any and all help is appreciated.

  2. #2
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861

    Re: Subtracting from Quantity in Stock

    Example:
    VB Code:
    1. newQuantity = CInt(intNumInStock) - CInt(intQuant)
    2.  
    3. strSql = "UPDATE products Set numInStock = " & newQuantity & " WHERE productNumber = " & intProductNumber
    4.  
    5. Conn.Execute(strSql)
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width