Results 1 to 2 of 2
  1. #1
    phil123 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2018
    Posts
    22

    Search using combo boxes

    Hi,



    I'm currently creating a search function using two combo boxes, let's call them x and y. I want the user to be able to select a value from x and y and search, but also to be able to select one from x and leave y blank (thus retrieving all records), and vice versa, so selecting a value from y and leaving x blank.

    I am using a query to perform this function and have worked out how to link this to the combo boxes using [forms]![formname]![comboboxname]. What I can't work out is what code to use to allow the field to be left blank. I have tried the following:

    Like "*" & [forms]![formname]![comboboxname] & "*"

    but I have now come to learn that this is just using a wildcard which is retrieving unrelated records (but which have some sort of commonality, such as a few similar letters).

    If anyone can suggest what code to use to allow both a blank value and a selected value that would be amazing!!

    Thank you

    Phil

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Test for a blank cbo 1st and change your search.

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

Similar Threads

  1. Search criteria of two combo boxes
    By sukhjinder in forum Programming
    Replies: 2
    Last Post: 08-16-2017, 06:44 PM
  2. Replies: 6
    Last Post: 05-24-2017, 08:06 AM
  3. Replies: 5
    Last Post: 09-22-2016, 08:42 AM
  4. Replies: 3
    Last Post: 01-04-2015, 06:09 PM
  5. Search using combo boxes
    By jakeao in forum Access
    Replies: 0
    Last Post: 05-18-2011, 12:17 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