Results 1 to 4 of 4
  1. #1
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581

    Search

    I'm trying to do a search for vehicle types. I have 4 types of vehicles in a table (1-marked car, 2-unmarked car, 3-truck, and 4-bicycle). I have a form that I'm using for the query to use for the criteria. I need for it to search all vehicles except for bicycles, or bicycles and no other type of vehicle. I set up a combo box on my form [cboVehicle]. It's an unbound combo box that I have set like a check box:

    Row Source: 1;Vehicle;2;Bicycle
    Row Source Type: Value List

    In my query, I tried to make my criteria: IIf(([Forms]![frmVehicleMileageSearch]![cboVehicle]=1),<>4,4)
    Access changes the criteria to: IIf(([Forms]![frmVehicleMileageSearch]![cboVehicle]=1),([qryVehicleMileageAll].[UnitTypeID])<>4,4)



    It will find the bicycles, but when I change the combo box to 1, it doesn't find anything.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    I don't use dynamic parameterized queries.
    The operation sign (=, <, >, <>) cannot be dynamic.

    I prefer VBA to build filter criteria. Review http://allenbrowne.com/ser-62.html
    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
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    A multi select listbox in conjunction with vba code is usually more useful for this than a combo. Pick 1, you search 1. Pick 3 values, you search on all three.
    Or do full blown search form as per link.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    The mulit select listbox sounds great. I want to learn how to do that. Unfortunately, that will confuse people here. This will be a better way here. I'm going through the sample database to learn that code. There's a lot to learn. I will probably be asking questions on it later. Thanks.

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

Similar Threads

  1. Replies: 3
    Last Post: 08-21-2018, 03:11 PM
  2. Replies: 3
    Last Post: 09-12-2016, 11:49 AM
  3. Replies: 1
    Last Post: 03-26-2015, 11:08 AM
  4. Replies: 3
    Last Post: 01-04-2015, 06:09 PM
  5. Replies: 3
    Last Post: 09-02-2013, 04:33 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