CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.

YesSoftware Forums -> Archive -> GotoCode Archive

 Calculation then Database Update

Print topic Send  topic

Author Message
Posted: 12/04/2003, 4:44 AM


Firstly, I'm using CCS, ASP and an Access Database.

Here's my problem:

I'm creating a simple application that will keep track of clients stock levels. Clients will be able to call off an amount of stock and when they do the Database is updated with the current stock level minus the amount they've just ordered. So, lets says a client has 10,000 of something currently in stock and they order 5,000, when the order is submitted the Database is updated with the new stock balance which is 5,000. This is my problem, I can not get the calculation to work and then update the Database when the order form is submitted.

On my order form I have an "Order Quantity" text box which the Client fills in with the amount they want to order. I need the amount which is entered into the "Order Quantity" box to be deducted from the "Stock Balance" field in my Database when the order form is submitted.

The Database table is called: selective
The Stock Balance field in the table is called: StockBalance
The Order Quantity field in the table is called: OrderQuantity

If you need any further information please ask.

Any help with this would be hugely appreciated.

Many Thanks,
Posted: 12/05/2003, 5:58 AM

Add a hidden field to the grid and assign the field StaockBalance to it.
Now do a before insert/update event where you set the value of the hidden field to the value of the field StockBlance - the value of the field OrderQuantity Use CCGetValue to obtain the vaues from the grid.
Posted: 12/07/2003, 11:11 AM

Thanks for replying RonB.

I tried what you said, but unfortunately I still cannot get it working properly. I've managed to get it half working though.

If the StockBalance was 10000 and I typed 5000 in the OrderQuantity field on the Form, I should get a new StockBalance value of 5000 once submitted. However, what I'm getting is -5000 as the new StockBalance value once the form is submitted. I'm assuming that my new hidden StockBalance field isn't picking up the original StockBalance value (10000) before the OrderQuantity value gets deducted.

Any further ideas on how I could fix this would be great but in the meantime I'll just continue with trial and error.

Thanks again,
Posted: 12/09/2003, 7:02 AM

change the hidden field to textbox for debugging and see if the value is present in the grid.I program in php so I can not give you an asp example.

Posted: 12/09/2003, 7:08 AM

Sorry, the reason i sugested changing to textbox is because the code seems to do what is should do (subtract)



These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit

Internet Database

Visually create Web enabled database applications in minutes.

Home   |    Search   |    Members   |    Register   |    Login

Powered by UltraApps Forum created with CodeCharge Studio
Copyright 2003-2004 by  and YesSoftware, Inc.