Problems with date-expression in Acces 97

  • Thread starter Thread starter Jeroen
  • Start date Start date
J

Jeroen

Does anyone have a solution for this (probably newbie)
problem:

I made a form to fill a table. In the form i've put a
date-expression so to automatic calculate the number of
weeks (datediff). In the form it works fine: in the
fieldbox is shows the exact number of weeks, however when
I open the underlaying table, the corresponding field is
empty. So in other words the data that is calculate in
the form-expression isn't stored in the corresponding
table.
 
Jeroen,

To begin with, ask yourself if you really need to store the number of weeks.
If it can be calculated on the basis of other stored data (in this case, the
two dates) then you don't need to store it, you just calculate it everytime
you need it (in queries, forms, reports etc).

If you still need to store it:
Under your current design the number of weeks is not stored because its
control on the form is not bound to the table field; I guess you are using
its ControlSoure property for the calculation expression.
The ControlSource property of the control should be set to the name of the
table field you wish to store it in. The expression that calculates the
number of weeks should be used in the Expression argument of a SetValue
action in a query fired by the On Change event both date controls on your
form. The idea is that the number of weeks control on the form is bound to
the table field (so as to store the information), displays the stored
information for existing records, and whenever you create a new record or
change one of the dates in an existing one the macro fires and calculates
the new value in the control (which is also saved in the table, the control
being bound).

HTH,
Nikos
 
Back
Top