IIF statement not working properly

ITguy1981

Registered User.
Local time
Today, 02:02
Joined
Aug 24, 2011
Messages
137
I currently have a field in a table called expiration date in which a dates are stored. In a form I added a text box that has an IIF statement

=IIf([Expiration Date]<Date(),"Expired",IIf([Expiration Date]=Date(),"Expires today","No"))

When in form view the box always says Expired no matter what the date is in [Expiration Date]

I don't see anything wrong with my IIF statement. plz help.
 
Looks okay to me too, and it worked in a brief test. Can you confirm that the field's data type is Date/time? Can you post the db?
 
Is "Expiration Date" the name of the control for the "Expiration Date" field?
 
Somehow my expiration date field got to text instead of date/time. Thank for the help.
 
No problem, glad you got it sorted out.
 
Without having to use the conditional formatting wizard type thing can I add color to my IIF statement by adding some extra code to it so I can have it report "Expired" in red and "Expires Today" in orange perhaps?
 
Conditional Formatting is probably easiest. You can use VBA code in the current event (for a form), but it will really only work properly if the form is in single view. It won't work like you want in continuous or datasheet views. In a report you can use the detail format event and you will get the desired view.
 

Users who are viewing this thread

Back
Top Bottom