Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2004
    Location
    chicago
    Posts
    26

    Red face Unanswered: Query won't return records with empty value in field Version: 2003 (11.0)

    I have created a form [frmFind] to populate another form based upon a query. In the query, I want to find the records with matched data in several fields. If nothing is in the field, then that will not be part of the criteria. All goes well except when I reach the date field [EffectiveDate]. If I don't want to filter by date, I put nothing in the [EffectDateSearch] field. However, when I execute the query, it will only return the records where [EffectiveDate] is not null, but i want to see them all.

    IIf([Forms]![frmFind]![EffectDateSearch] Is Null,[EffectiveDate],[Forms]![frmFind]![EffectDateSearch])

    I have used this logic on other fields in the query and it works fine. Any suggestions? Thanks, i rarely use Access. I am sorry to be a bother.

  2. #2
    Join Date
    Apr 2004
    Location
    metro Detroit
    Posts
    634
    Try using a wildcard (*).

  3. #3
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    You could try :

    Like IIf(IsNull([Forms]![frmFind]![EffectDateSearch]),*,[Forms]![frmFind]![EffectDateSearch])
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  4. #4
    Join Date
    Mar 2004
    Location
    chicago
    Posts
    26
    StarTrekker:
    when I execute the query criteria you suggest, it will only return the records where [EffectiveDate] is not null, but i want to see them all.

  5. #5
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Code:
    WHERE   some_field = @variable
    OR      @variable IS NULL
    George
    Home | Blog

  6. #6
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Try:

    Like IIf(IsNull([Forms]![frmFind]![EffectDateSearch]),*,[Forms]![frmFind]![EffectDateSearch]) or Is Null
    Last edited by StarTrekker; 06-10-08 at 23:23.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

Posting Permissions

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