Results 1 to 5 of 5
  1. #1
    cap.zadi is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2011
    Location
    KSA
    Posts
    481

    Status field in Query!

    Hi



    I am looking for help to correct the below expression for query?

    It is required to identify the status of employee if;

    Available = If any of AStartDate or AEndDate is Null
    On Vacation: If current date is in between AstartDate and AEndDate
    Already Applied: if current date is still not reached to Astart Date.

    Status: IIf(Nz([AStartDate],0)=0 Or Nz([AEndDate],0)=0,"Available",IIf([AStartDate] >= Now()," and [AEndDate] < = Now(), "Vacation","Already Applied "))

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    Remove the IIFs, and make 2 queries:
    1 for the Nulls,
    1 for the rest.

  3. #3
    cap.zadi is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2011
    Location
    KSA
    Posts
    481
    Sir

    Thanks like? can you show example?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    If you want to show all employees and their status, just one query.

    Remove comma and quote mark before the and operator.

    Now() function returns date and time. You should probably use Date() which returns only date.

    I think the operators are backwards for the "Vacation" calc.

    Status: IIf(IsNull([AStartDate]) Or IsNull([AEndDate]), "Available", IIf([AStartDate] <= Date() And [AEndDate] >= Date(), "Vacation", "Already Applied "))

    Save query and then can apply filter criteria to the constructed Status field for report output.
    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.

  5. #5
    cap.zadi is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2011
    Location
    KSA
    Posts
    481
    Hi

    Thanks and it worked.

    regards

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

Similar Threads

  1. Replies: 9
    Last Post: 02-24-2017, 07:12 AM
  2. Field Status Change Automatically?
    By m4l4y in forum Access
    Replies: 2
    Last Post: 03-23-2016, 06:55 PM
  3. Replies: 2
    Last Post: 12-04-2014, 11:09 AM
  4. Replies: 7
    Last Post: 09-29-2014, 03:25 PM
  5. Replies: 3
    Last Post: 06-19-2014, 03:47 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