Results 1 to 3 of 3
  1. #1
    Buns1976 is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    16

    Need help with a search query

    Hi Everyone,



    I am very new to Access and need some help with some queries. I have one Table that contains a Date, PLUNumber, Description, PriceEach, ItemsSold, and TotalSales fields.

    I have a date range query already set up but I am looking for a way to enter a scan or type a description in a search box with a date range picker
    and show that item for the dates selected.

    Any help would be greatly appreciated.

    Thank you!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    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
    theviking is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Location
    Northern New Jersey
    Posts
    15
    As Allen Browne states, dynamically generating a where clause through code is the most efficient way to filter your records. However if you are not yet comfortable with coding you can get around the issues he describes with using a Like statement with the Nz function. Build a query which mirrors your base table. Use a Like statement as indicated to filter the query based upon an unbound form field. But instead of your search criteria executing directly against the table column, create a new column with an Nz function against your search field to ensure the table column is always populated. Otherwise as Allen indicates, any nulls will be excluded from your search results.

    Something like this (no pun intended
    Click image for larger version. 

Name:	QueryLikeNz.jpg 
Views:	13 
Size:	49.0 KB 
ID:	37672

    To search on a date column you would typically use a Between statement with the same type of logic.
    Click image for larger version. 

Name:	QueryLikeNzDate.jpg 
Views:	13 
Size:	55.3 KB 
ID:	37673

    Again, I'm not recommending this as the best way for an experienced developer to filter form records. Functions and Like statements with wildcards in queries are generally inefficient so in a very large table you will definitely see a performance hit. But in a smaller table against an Access db it's not noticeable and the level of effort (and expertise) is greatly reduced over coding your where clause. You can literally write these in minutes.

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

Similar Threads

  1. Replies: 3
    Last Post: 03-16-2017, 11:22 AM
  2. Replies: 10
    Last Post: 09-08-2016, 08:09 PM
  3. Search Query
    By gehrenfeld in forum Queries
    Replies: 4
    Last Post: 07-17-2015, 05:50 AM
  4. Search Query
    By Mahendra1000 in forum Access
    Replies: 3
    Last Post: 09-19-2013, 05:44 AM
  5. Search Query
    By convey2web in forum Queries
    Replies: 3
    Last Post: 11-08-2010, 02:27 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