Update date Calc.

  • Thread starter Thread starter Owen Wilson
  • Start date Start date
O

Owen Wilson

Hi,

I have a text box that uses the DateDiff function to
calculate the elapsed time between an initial event
and "today". Is there a way to get this to automatically
update?

Code: DaysOFA.Value = DateDiff("d", Date1, Date)

TIA,

Owen
 
"Automatically update" in what way? As you move from record to record? Put
your code in the form's Current event. As the value of Date1 changes? Put
your code in the AfterUpdate event of that control.
 
Owen,
You didn't say what event that code was triggered by, and... is
InitialEvent a Date field on your form?
If you are saving DaysOfA to a table, then you'll have to use the
AfterUpdate of InitialEvent... with your code
DaysOFA.Value = DateDiff("d", InitialEvent, Date())
That will automatically update whenever InitialEvent changes, and... of
course that value will be stored.

If you don't need to save DaysOfA, or DaysOFA is an "on the fly"
calculation, then an unbound text control with a ControlSource of...
= DateDiff("d", InitialEvent, Date())
will alway display the correct difference automatically... when InitialEvent
changes, or the next time you visit the record and the Date() has changed.

hth
Al Camp
 
Back
Top