Results 1 to 2 of 2
  1. #1
    baulrich is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    23

    Form-based query to return matched value or all records including NULLs

    I have a query that is based on a combo-box on a form. (Actually it's on a text box, which has a value based on the combo-box selection.

    The text box expression is: =IIf(IsNull([combo_job_category].[Column](0)),"*",[combo_job_category].[Column](0))

    - which says in English: If the user chooses an item from the list, use it as the query criteria.... otherwise use "*" as the query criteria.

    Then, in the query itself.... The field in question (job_category) is filtered with this criteria. Note that job_category

    Like [Forms]![frm_job_Filter]![search_job_category]

    The problem with this is, it only works if the user has selected a combo-box item. If they haven't, they query doesn't return records where job_category Is Null.

    So I tried"

    Like [Forms]![frm_job_Filter]![search_job_category] or Is Null

    The problem with this is, it does include the records where job category Is Null.... even if the user has selected a combo-box item.

    What can I do, with access query builder, to search for the item if a combobox item is selected, but if not.... show all records, including nulls.



    thanks in advance...

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Try wildcard in the query parameter:

    Like [Forms]![frm_job_Filter]![search_job_category] & "*" Or Is Null

    If that doesn't work try using a query that forces a value for all records, even the nulls. For text fields:

    Nz([fieldname], "")

    or

    Nz([fieldname], "none")

    Then just use the wildcard in the query parameter under that constructed field.
    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.

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

Similar Threads

  1. Replies: 5
    Last Post: 05-01-2013, 11:39 AM
  2. Replies: 2
    Last Post: 03-07-2013, 03:14 PM
  3. Last matched item in an unmatching query
    By kabaa01 in forum Queries
    Replies: 0
    Last Post: 05-19-2010, 03:46 PM
  4. Replies: 2
    Last Post: 01-18-2010, 11:52 AM
  5. Replies: 5
    Last Post: 10-08-2009, 05:15 AM

Tags for this Thread

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