AllExperts > Using MS Access 
Search      
Using MS Access
Volunteer
Answers to thousands of questions
 Home · More Using MS Access Questions · Answer Library  · Encyclopedia ·
More Using MS Access Answers
Question Library

Ask a question about Using MS Access
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About 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

 
   

You are here:  Experts > Computing/Technology > Business Software > Using MS Access > IIF Statment

Using MS Access - IIF Statment


Expert: Scottgem - 7/8/2009

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


Add to this Answer   Ask a Question


 
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.