This topic is locked

simple decrement field value

5/4/2009 4:32:04 AM
ASPRunnerPro General questions
author

I have a simple stock level app. One table holds a [quantity] of stock. I need to edit this and decremnt value by 1 from another table. Do I use sql, ado or dal to make this as easy as poss.
Thanks.

Sergey Kornilov admin 5/4/2009

Here is the simple SQL query that decreases the quantity
sql = "update table name set quantity=quantity-1 where id=..."

dbConnection.Execute sql
You need to put actual field names there and correct record id

4983 5/10/2009

I have a simple stock level app. One table holds a [quantity] of stock. I need to edit this and decremnt value by 1 from another table. Do I use sql, ado or dal to make this as easy as poss.

Thanks.


Thanks. Maybe you could help with 2 problems around this. I have a AssignedToUsers stock table and a Stock table
AssignedToUsers

assignedtouserid

stock code

username

dateassigned
and this table
Stock

stockid


stok code

quantity
As i add record to assignedtousers table i want to decrease the quantity count in the stock table by 1. What/where do i need to place the update ?
Anything to help clear the confusion would be appreciated.

quantity

J
Jane 5/11/2009

Hi,
use After record added event for AssignedToUsers table.

Here is just a sample:

sql = "update Stock set quantity=quantity-1 where [stock code]=" & dict("stock code")

dbConnection.Execute sql