Is Timer event proc to systematically test when a date is reached?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to test a field (ContractEndDate) against the current system's date
(now()). If ContractEndDate = now() Then
I need to switch the ContractStatus = "Closed" and
also update a new associated contract extended record's status to "Active"
Else
ContractStatus = ContractStatus for the current record and
the new extended contract record's status will still be "not active"
End If

Would I put this code under the timer event procedure or use a DateDiff
function?
Can you please guide me where to implement this. I'm totally lost on how to
go about coding this.
Thank you!!
 
I need to test a field (ContractEndDate) against the current system's date
(now()).

I'd suggest using Date() rather than Now(). Date() returns today's
date from the system clock; Now() returns the current date and time
accurate to microseconds. For your expression to work, you would need
to wait up until midnight... and press the Enter key at EXACTLY the
right instant! said:
If ContractEndDate = now() Then
I need to switch the ContractStatus = "Closed" and
also update a new associated contract extended record's status to "Active"
Else
ContractStatus = ContractStatus for the current record and
the new extended contract record's status will still be "not active"
End If

Would I put this code under the timer event procedure or use a DateDiff
function?

I think all you need to do is - once a day - run an Update query
updating the fields, using a criterion

=Date()

on the ContractEndDate. You don't need a Timer to do this, in fact it
would be quite inappropriate!

John W. Vinson[MVP]
 
John Vinson said:
I'd suggest using Date() rather than Now(). Date() returns today's
date from the system clock; Now() returns the current date and time
accurate to microseconds. For your expression to work, you would need
to wait up until midnight... and press the Enter key at EXACTLY the


I think all you need to do is - once a day - run an Update query
updating the fields, using a criterion

=Date()

on the ContractEndDate. You don't need a Timer to do this, in fact it
would be quite inappropriate!

John W. Vinson[MVP]

John,
Thanks for simplifying this. I'll just add the check vs. the Date() when the
user first opens the Main Form.

Would I need to check that it only updates once?

Thank you!
 
Back
Top