Results 1 to 3 of 3
  1. #1
    JimO is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Dec 2015
    Posts
    126

    Filter from 2 Combo Boxes

    Having a problem getting this to work. I have tried a number of variations but it has been by trial and error.


    Any ideas would be appreciated.


    Code:
       Me.Filter = ""
        Me.FilterOn = False
        Me.Filter = "[ConstCmb].[Column](0) = '" & Me.[ConstructorCmb].[Column](0) & "' "
        Me.FilterOn = True
    Source for both [ConstCmb] and [ConstCmb];


    Code:
    SELECT [ConstID], [Constructor] FROM AutoConstructorT ORDER BY Constructor;
    Run-time error '3709'
    The search key was not found in any record.

    Thanks
    Jim O

  2. #2
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Not quite sure what you are trying to do, but maybe this will help.

    When you are setting a filter, you are picking a FIELD in the form record source to limit records.

    It looks like the field "ConstID" is the PK field for the table. If so, then setting a filter using "ConstID" will return one record.


    Here is an example for filtering on "ConstID":
    (assuming "ConstID" is a number type field)
    Code:
        Me.Filter = ""
        Me.FilterOn = False
        Me.Filter = "ConstID = " & Me.ConstCmb '(usually, the first field is the bound field, so the ".Column(0)" is not needed)
        Me.FilterOn = True

    Here is an example for filtering on "Constructor":
    (assuming "Constructor" is a text type field)
    Code:
        Me.Filter = ""
        Me.FilterOn = False
        Me.Filter = "Constructor = '" & Me.ConstructorCmb.Column(1) & "'"  '(brackets not needed - you are referring to a control on a form, not a field)
        Me.FilterOn = True

  3. #3
    JimO is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Dec 2015
    Posts
    126
    Thank you very much for the help. It is doing what I wanted. I did change = to LIKE to show all records that fit the search criteria.


    Thanks
    Jim O

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

Similar Threads

  1. Filter with multiple Combo boxes
    By dotcanada in forum Access
    Replies: 3
    Last Post: 09-01-2016, 01:19 PM
  2. Filter subform with two combo boxes
    By dotcanada in forum Forms
    Replies: 4
    Last Post: 07-25-2015, 05:20 PM
  3. Help using 2 combo boxes to filter form
    By umpersav in forum Programming
    Replies: 2
    Last Post: 07-13-2015, 12:29 PM
  4. Filter listbox, using combo boxes
    By EthanMoist in forum Forms
    Replies: 8
    Last Post: 05-22-2013, 11:36 AM
  5. Filter based on two combo boxes.
    By jakeao in forum Programming
    Replies: 1
    Last Post: 05-22-2011, 10:56 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