Results 1 to 3 of 3
  1. #1
    AdamN is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2012
    Posts
    5

    Query Asking For Input after enabling Criteria

    I am using Access 2003 and am having problems with a Query.

    Attached is the SQL Code:

    Code:
    SELECT tbl_members.NameFirst, tbl_members.NameLast, tbl_members.Medical, tbl_members.DOB, Format(IIf(IsNull(tbl_members!DOB),"",IIf(IsNull(tbl_members!Medical),"",IIf(DateDiff("yyyy",tbl_members!DOB,tbl_members!Medical)+(Format(tbl_members!DOB,"mmdd")>Format(tbl_members!Medical,"mmdd")) Between 37 And 39,DateAdd("yyyy",42,DateAdd("d",-1,tbl_members!DOB)),IIf(DateDiff("yyyy",tbl_members!DOB,tbl_members!Medical)+(Format(tbl_members!DOB,"mmdd")>Format(tbl_members!Medical,"mmdd")) Between 40 And 64,DateAdd("yyyy",2,tbl_members!Medical),IIf(DateDiff("yyyy",tbl_members!DOB,tbl_members!Medical)+(Format(tbl_members!DOB,"mmdd")>Format(tbl_members!Medical,"mmdd")) Between 18 And 36,DateAdd("yyyy",5,tbl_members!Medical),"Error!"))))),"Medium Date") AS ExpiryDate, tbl_members.Status, tbl_members.Initials, tbl_members.CurrentRank, tbl_units.UnitNumber, tbl_units.Element, tbl_acis.ACI, tbl_acis.Element, tbl_acis.ShortGrouping, IIf(IsNull(tbl_members!Medical),"",DateDiff("d",Date(),[ExpiryDate])) AS DaysToExpiry
    FROM (tbl_members INNER JOIN tbl_units ON tbl_members.UIC = tbl_units.ID) INNER JOIN tbl_acis ON tbl_units.ACI= tbl_acis.ID
    WHERE (((tbl_members.Status)=1) AND ((IIf(IsNull([tbl_members]![Medical]),"",DateDiff("d",Date(),[ExpiryDate])))<1));
    For a reason that I cannot determine, if I enable criteria on the filter, for example <1, it prompts with a screen "Enter Parameter Input" for ExpiryDate. If I don't have criteria entered, it does not ask for input.

    What I am trying to filter the criteria where the date difference is less than 1 day or the meidcal date field is null.



    I am sure I am not understanding something correctly, but I just don't know what.

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    To set a criteria, you need a field, an operator and a value. The first part of the WHERE clause is


    Code:
    WHERE (((tbl_members.Status)=1)
    So the field is "STATUS", the operator is "Equals" and the value is 1.
    In the 2nd part of the criteria, you have

    Code:
    ((IIf(IsNull([tbl_members]![Medical]),"",DateDiff("d",Date(),[ExpiryDate])))<1));
    No field, no operator, just a value??? (the result of the IIF() function)

  3. #3
    AdamN is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2012
    Posts
    5
    I think I figured out my issue, now just trying to solve it. Once I do I will post solution.

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

Similar Threads

  1. Criteria based on user input
    By Alsail77 in forum Queries
    Replies: 5
    Last Post: 08-16-2012, 02:19 PM
  2. Replies: 5
    Last Post: 08-02-2012, 09:44 AM
  3. Selecting records based on criteria from user input
    By shabbaranks in forum Programming
    Replies: 1
    Last Post: 01-04-2012, 09:06 AM
  4. Criteria issue when using user input and > < ect
    By scotty562 in forum Queries
    Replies: 3
    Last Post: 11-11-2010, 11:08 AM
  5. Replies: 6
    Last Post: 07-22-2010, 05:53 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