Results 1 to 4 of 4
  1. #1
    DelbyJones is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    11

    Struggling with IIf expression with date in query

    I have a query that I want to return "due by 9/8/14" if the [Grace] field is blank or if the date in that field is before 9/8/14. If the date in the field is after 9/8/14, I want it to return "valid through (the date in the field)"



    I wrote: MedWords: IIf([Grace]=Null,"due 9/8/14",IIf([Grace]<9/8/14,"due 9/8/14","valid through " & [Grace])) and all I get is "valid through" and either blank, or whatever date is in the [Grace] field.

    Can someone tell me what I am doing wrong?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Are you in the U.S.? Is that example date for Sept 8, 2014?

    Cannot use =Null.

    Try:

    IIf(IsNull([Grace]) Or [Grace] < #9/8/14#, "due 9/8/14", "valid through " & [Grace])

    or

    IIf(Nz([Grace],#1/1/1900#) < #9/8/14#, "due 9/8/14", "valid through " & [Grace])

    Problem with this code is you will have to remember to modify it every year.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Xarkath is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Location
    Millcreek WA
    Posts
    92
    try this:

    IIf(IsNull([Grace]),"due 9/8/14",IIf([Grace]<#9/8/14#,"due 9/8/14","valid through " & [Grace]))

  4. #4
    DelbyJones is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    11
    YES! It worked! Thank you!!! I can change the date yearly, that is NO problem. Again, thank you SO much. You just made my year!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Struggling with working hours query
    By sdel_nevo in forum Queries
    Replies: 6
    Last Post: 08-09-2014, 01:43 AM
  2. Replies: 11
    Last Post: 04-11-2014, 04:26 PM
  3. Struggling with this query
    By ramangill in forum Queries
    Replies: 8
    Last Post: 04-10-2014, 09:14 PM
  4. struggling with query, plz help
    By jimgros in forum Queries
    Replies: 2
    Last Post: 07-26-2011, 03:35 AM
  5. Error in query expression Date()
    By boywonder in forum Queries
    Replies: 15
    Last Post: 12-26-2010, 06:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums