Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2004
    Posts
    8

    Unanswered: Update ComboBox Based on Filter

    Hi, I have a combo box on a form used to find records on the form. When I do a filter, the combo box still shows all records. I want it to show only the filtered records. What code to write? Thanks.

  2. #2
    Join Date
    Apr 2003
    Location
    Alabama, USA
    Posts
    154
    So you have a Form with a combobox (bound to a primary key) used to filter the records shown in a sub-form (filtered on a foreign key which is the same as your primary key on the combobox on the main form)?? If so, the combobox which is in the main form will always show all the available records.

    Did I understand your question properly?
    http://AccessDB.Info

    You live and learn. At any rate, you live. - Douglas Adams

  3. #3
    Join Date
    Jun 2004
    Posts
    8
    I dont have a subform. The combo box is used to find a particular record in the form. I created it using the combo box wizard and selected the option "Find a record in my form based on the value I selected in the combo box". Then I created command buttons: A,B,C..... When I click button "A", the form will be filtered to all Last Names starting with "A" only and so on... I also want the combo box to show also all Last Names starting with "A". But when i click the combobox, it still shows all records with no filter.

  4. #4
    Join Date
    Apr 2003
    Location
    Alabama, USA
    Posts
    154
    If you open the properties for your combobox and look in the data tab under "Row Source". Click the button at the right, the one with three dots (...). You will open up a query design window. This is the query that is used to populate your combobox. You will need to add criteria to it to filter it the same way your form is being filters.

    e.g.
    Left([LastName],1) = "T"
    or
    Left([LastName],1) = me.txtFilterOn '(where txtFilterOn is used to filter your form)

    Hope this helps!
    http://AccessDB.Info

    You live and learn. At any rate, you live. - Douglas Adams

  5. #5
    Join Date
    Jun 2004
    Posts
    8
    Thanks Cosmos75. It worked!

  6. #6
    Join Date
    Apr 2003
    Location
    Alabama, USA
    Posts
    154
    DeoM,

    Glad to hear it!
    http://AccessDB.Info

    You live and learn. At any rate, you live. - Douglas Adams

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •