Using MS Access/IIF Statment

Advertisement


Question
QUESTION: 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.

Answer
Try
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

Using MS Access

All Answers


Answers by Expert:


Ask Experts

Volunteer


Scottgem

Expertise

I can answer almost all types of questions relating to Microsoft Access usage and application design. My strengths are database and interface design.

Experience

I've been designing databases for over 15 years working with dBase, FoxPro, Approach and Access.

Organizations
Author of Microsoft Office Access 2007 VBA
Techncial Editor for Special Edition Using Microsoft Access 2007 and Access 2007 Forms, Reports & Queries From Que Publishing

©2012 About.com, a part of The New York Times Company. All rights reserved.