Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2015
    Posts
    1

    Unanswered: Query help with IIF statements

    Hello,

    I was hoping that someone could provide assistance with a question I have. I'm currently working on a database and cannot understand how to get an expression within a query to work.

    Within a query I'm trying to have a field return a "YES" or "NO". Yes if a report was approved before the ship date and a no if not.

    I have two fields to work with. [APP_DATE] for approval date of a report and [SHIP_DATE] for the ship date. I thought of using IIF statement but cannot get it to work. I have tried the below:

    Status:IIF([APP_DATE]<[SHIP_DATE],"YES","NO")

    Any help you can provide would be much appreciated.

    Thank you in advance.

  2. #2
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Don't know what to tell you; as a Calculated Field your syntax of

    Code:
    Status:IIF([APP_DATE]<[SHIP_DATE],"YES","NO")
    works just fine, for me! Made up a Table with fields APP_DATE and SHIP_DATE, created a Query with it, then pasted your code directly into a new Field in the Query Design View. The SQL Statement would be something like:

    Code:
    
    SELECT TableName.APP_DATE, TableName.SHIP_DATE, IIf([APP_DATE]<[SHIP_DATE],"YES","NO") AS Status
    FROM TableName;
    If you can save the file in v2007 or earlier format, Zip it up and attach it to a post, here, I'd be happy to look at it.

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •