Formulas

  • Thread starter Thread starter Norm
  • Start date Start date
N

Norm

I have been able to create a pretty good data base except
that it does not calculate due dates. The due dates when
I get them to calculate does not go to the table in which
case I can no longer run the Query on the due date. WHen
I take the calculation out what I type in will appear in
the table and I can run the Query.

Does anyone know how I can do both?
 
As a general rule we do not store the result of a calculation in a
relational database, but recalculate it as required. That way we can be sure
that it is always based on up-to-date data. If you store it, you then have
to be very careful that it is always recalculated and re-stored whenever the
data on which it is based changes.

That said, if you still want to store the result, you need to add code to
the AfterUpdate event of each control on the form that is involved in the
calculation. For example, suppose you have three fields in a table, NumOne,
NumTwo, and Result, and three corresponding text boxes on a form, txtNumOne,
txtNumTwo, and txtResult. You would add something like the following to the
AfterUpdate events of both txtNumOne and txtNumTwo:

If Not IsNull(Me!txtNumOne) And Not IsNull(Me!txtNumTwo) Then
Me!txtResult = Me!txtNumOne * Me!txtNumTwo
End If

You would usually set the Locked property of txtResult to True, as you will
not want users overwriting the calculated result.
 
Back
Top