ramasule
03-14-2007, 02:37 PM
Hello,
I was wondering how to check a date in a table vs current date and
then put a yes/no in a colum if the date in the table is past current date.
In the form I know it should be wrote in the Upon Open Event
But I am unsure of the code.
Thank you for your time,
Derek L
The_Doc_Man
03-14-2007, 04:32 PM
This is actually an UPDATE query situation, unless you really, REALLY, REALLY wanted it in form code.
Just do an update to the YES/NO column if the stored date is > Now() (for true Date fields) or CDate([stored date]) > Now() (for text-form dates).
You would put the indicated expression as the update value for the Yes/No field and you could use the Expression Builder to help you build that.
ramasule
03-15-2007, 06:13 AM
Ok so I have
=IIf(Projects![Date Expired]>=Now(),-1,0)
Where do I put this?
I tried putting it in the before update, then the after update niether worked.
Also is it easy to do a ( Now() - #00/01/00# ) to let me know when
it is about to expire.
The_Doc_Man
03-16-2007, 04:38 PM
IIF is not what you want.
In the Update query grid, there is a place where you put the value that you want to stuff into the field.
Put an expression such as ( [tabledate] < Now() ) with a relational operator between the date fields. The relational operator yields a value of TRUE or FALSE (Yes or No). Store the result of that expression into the Yes/No field and suddenly you have something you can use in subsequent queries.
You can do such a thing as a DateDiff() - a function taking the difference between two dates and giving back the answer in selected units. "About to expire" is a relative and highly subjective term. If you can define the criteria you want to apply in a particular set of units, I'd bet that DateDiff is the way to do at least part of that computation.
Wiz47
03-17-2007, 02:00 AM
Ok so I have
=IIf(Projects![Date Expired]>=Now(),-1,0)
Where do I put this?
I tried putting it in the before update, then the after update niether worked.
Also is it easy to do a ( Now() - #00/01/00# ) to let me know when
it is about to expire.
WHERE (Date Expired-1)=Date()
Will match the date one day before it is due to expire when using a query.
Storing this is pointless, just use a calculated control