Results 1 to 7 of 7
  1. #1
    Hamm is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2012
    Posts
    27

    Multiple Search Boxes

    Hi Guys

    I have set up a query to search my table based on a number of different search boxes. ie each column has a search box and the idea is to filter the table by any combination of the search boxes.
    The searching appears to be working except it is not showing records with blanks in any of the searchable columns.

    I tried using:

    Nz([forms]![Home Screen]![SrchTextNumber],"")=""

    but obviously this only works when I enter something in the SrchTextNumber search box. I want to be able to create a statement that basically says if all the search boxes are empty then show all records.

    Does anyone have any idea of how i can get this done?

    Thanks

    Here is My SQL for reference:

    SELECT Assets.[Job Number], Assets.[Project Name], Assets.Size, Assets.[Service Line], Assets.[Assignment Type], Assets.Client, Assets.[Property Name], Assets.City, Jobs.Country, Assets.[Project Leader], Jobs.[Date Billed], Assets.[Job ID], Assets.[Archive Location]
    FROM Jobs INNER JOIN Assets ON Jobs.ID = Assets.[Job ID]
    WHERE (((Assets.[Job Number]) Like "*" & [forms]![Home Screen]![SrchTextNumber] & "*") AND ((Assets.[Project Name]) Like "*" & [forms]![Home Screen]![SrchTextProject] & "*") AND ((Assets.Size) Like "*" & [forms]![Home Screen]![SrchTextSize] & "*") AND ((Assets.[Service Line]) Like "*" & [forms]![Home Screen]![SrchTextService] & "*") AND ((Assets.[Assignment Type]) Like "*" & [forms]![Home Screen]![SrchTextAssignment] & "*") AND ((Assets.Client) Like "*" & [forms]![Home Screen]![SrchTextClient] & "*") AND ((Assets.[Property Name]) Like "*" & [forms]![Home Screen]![SrchTextAsset] & "*") AND ((Assets.City) Like "*" & [forms]![Home Screen]![SrchTextCity] & "*") AND ((Jobs.Country) Like "*" & [forms]![Home Screen]![SrchTextCountry] & "*") AND ((Jobs.[Date Billed]) Like "*" & [forms]![Home Screen]![SrchTextDate] & "*")) OR ((Nz([forms]![Home Screen]![SrchTextNumber],"")=""));

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,920
    If fields are allowed to be empty, ie, Null, then need to handle the null. Create field with expression using the Nz function and apply the wildcard filter criteria to 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.

  3. #3
    Hamm is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2012
    Posts
    27
    Hi June7

    Can you please expand? How exactly should the Nz expression read? and do I simply use * as an OR in my query or an AND?

    thanks
    Hamm

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725

  5. #5
    Hamm is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2012
    Posts
    27
    Thanks Orange but i have already achieved that. My issue is with records which have blank fields under something i am searching for. The query doesn't show any of these records.

  6. #6
    Hamm is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2012
    Posts
    27
    Thanks guys, i have now got it working. My fields needed to be expressions based on the Nz function to change Null Values to "" rather than straight fields from the table

  7. #7
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725

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

Similar Threads

  1. Replies: 12
    Last Post: 03-22-2012, 02:48 AM
  2. Search Form - Cascading Combo Boxes
    By WeeTerrier in forum Forms
    Replies: 7
    Last Post: 12-05-2011, 08:26 PM
  3. Search using combo boxes
    By jakeao in forum Access
    Replies: 0
    Last Post: 05-18-2011, 12:17 PM
  4. 2 multi select list boxes on one search form
    By woodey2002 in forum Forms
    Replies: 2
    Last Post: 11-05-2010, 12:44 PM
  5. Search form with list boxes
    By scottay in forum Programming
    Replies: 15
    Last Post: 07-27-2010, 09:28 AM

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