-1

I'm making a form/table combo that will calculate the value of a computer based on the length of time you've had it.

"Purchase price" and "Current price" are both defined as decimal variables. The rest have been defined as integers.

In the form, in the "Current price" text box, in the OnValidate area, I've put

Monthcalc := "Current month" + (12-"Purchase month") + ( 12* ("Current year (20xx)" - "Purchase year (20xx)"));
"Current price" := "Purchase price" * POWER((1-0.025),Monthcalc)

However, when I run the form and enter values, the value is "0" in the Current Price field. Why could this be?

hivert
  • 10,579
  • 3
  • 31
  • 56

1 Answers1

1

OnValidate is triggered, when you enter a value into that field manually.

Assuming this is a form with no table behind it you should put this code behind the OnValidate / OnAfterValidate trigger of each field where you enter data.

Normally I would put the code into a function within the form and then call this function at all these locations.

If the data is in a table and needs to be calculated for each line, OnAfterGetRecord is one of the triggers where this works.

576i
  • 7,579
  • 12
  • 55
  • 92