Using MS Access/IIF Statment
Expert: Scottgem - 7/8/2009
QuestionQUESTION: Hello,
I am working on a query that has mutliple dates.
This is the table structure
RequiredStart
RequiredEnd
Signature1
Signature2
...
I am trying to build an IIF statment for a column in a query to say either Violation or In Compliance.
Signature 1 and Signature 2 need to fall within the RequiredStart and RequiredEnd. If that is the case the field should dispaly In Compliance if they are not both within the dates it should say Violation.
Also if one of the dates are missing it would say violation.
This is what I have so far
Violation: IIf([Signature1] Between [RequiredStart] And [RequiredEnd],"In Compliance","Violation")
I could not find a good example of a nested date expression.
Please help if you can
Thanks
Ryan
ANSWER: This isn't a nested anything. Try it this way:
IIF([Signature1] > [RequiredStart] AND [Signature1] < [RequiredEnd],"In Compliance","Violation")
Hope this helps,
Scott<>
Microsoft Access MVP 2007
Author: Microsoft Office Access 2007 VBA
---------- FOLLOW-UP ----------
QUESTION: Yes that works however it does not incorporate signature 2. Can this be done in one statement? It should be a violation if signature 2 is also missing or otuside of the required start and end.
AnswerTry
IIF(([Signature1] > [RequiredStart] AND [Signature1] < [RequiredEnd]) AND (Signature2] > [RequiredStart] AND [Signature2] < [RequiredEnd]),"In Compliance","Violation")
Hope this helps,
Scott<>
Microsoft Access MVP 2007
Author: Microsoft Office Access 2007 VBA