Results 1 to 2 of 2

Thread: Blank Criteria

  1. #1
    Join Date
    Sep 2002
    Posts
    2

    Question Unanswered: Blank Criteria

    I am using the expression [Enter Date:] in the criteria of the date field in a query. How do I make it so that if nothing is entered (or if "all" is entered) in the criteria box, all dates are shown.

    Thanks,
    FarmerJoe

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002

    Re: Blank Criteria

    where
    iif([Enter Date:]='',0,iif([Enter Date:]='all',0,1))=0
    or [Enter Date:]=thedatefield

    in english:

    if [Enter Date:] is a zero-length string or the string 'all', then the first condition is 0=0 which is obviously true for every row in the table, and since this is combined with OR, it doesn't matter what the other condition evaluates as

    if [Enter Date:] is anything else, the first condition is 1=0 which is false for all rows in the table, so then the second condition determines which rows are selected

    neat, eh?

    rudy
    http://rudy.ca/

Posting Permissions

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