This topic is locked

Execute calculation with readonly field

2/27/2007 7:14:30 AM
ASPRunnerPro General questions
Z
zion4ever author

Hi,
I have two questions.

I have some values that are read from a Mysql db.

I would like to setup some basic calculations.
Say I have a field called "In stock" and another field called "sold" and a field called "Base stock"

Now each time a new entry is added (add form) the stock field should contain the value of the BASE STOCK minus Qty Sold goods OF THE PREVIOUS ENTRY
So suppose I have an entry BASE STOCK = 10 AND SOLD = 5 then everytime a new entry is added the base stock of the new entry must be the calculation of the previous entry. How can I achieve this?
Second, it seems that something like
Dim Stock

Dim Sold

Dim Total
Stock =dict("base_Stock")

Sold = dict("Sold")

Total = clng(val(stock)) - clng(val(sold))
dict("CalculatedTotal") = Total
works only when all field are textfield. If one of them is readonly, it returns a zero even if it hold another value.
Plz help me out with these 2 questions
Hans

J
Jane 2/27/2007

Hans,
please see my answers below:

  1. you can do it using Before record added event on the Events tab. Save value of Qty Sold goods field in the Session variables and then use it in the event. Here is a sample:
    dict("stock field")=dict("base stock")-Session("Qty Sold goods")



where Qty Sold goods, stock field and base stock are your actual field names.
2. values of readonly fields aren't in the dict collection. You need to uncheck this field from the edit page on the Choose fields tab and then use your code in the event.

Z
zion4ever author 2/27/2007

Hans,

please see my answers below:

  1. you can do it using Before record added event on the Events tab. Save value of Qty Sold goods field in the Session variables and then use it in the event. Here is a sample:
    where Qty Sold goods, stock field and base stock are your actual field names.
  2. values of readonly fields aren't in the dict collection. You need to uncheck this field from the edit page on the Choose fields tab and then use your code in the event.


Jane,

  • Why is it that base stock and stock are used in conjunction with dict and qty sold in conj. with session?
  • can you plz help me with the other question regarding getting the values of the previous BASE STOCK and SOLD values from the last entry in db? (so i can base my calc on those values)
    TIA
    Hans