Results 1 to 2 of 2
  1. #1
    Trilback is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Posts
    1

    Post Apply FIlter from Combo Box


    I have a forum with a subforum that I am trying to make so that if I select a combo box I can sort based on fields from that table. Ex would be a table that has people and there address. I want combo boxes so I can filter by city or state. Right now on my table/forum I have PHYSICAL CITY and PHYSICAL STATE also I need a text box to be able to search via a person ID number that they are given. I tried to look online and try and few things but nothing seems to work. I just have a single Access database that I have on my computer and I am on only one using it. I also am using access 2013

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    make a continuous form of People, frmList.
    In the header put a combo box for state and 1 for City.
    make 2 queries:
    1 to filter Cities for the picked State, qsCity1State ;
    1 no filter , all cities, qsCitiesAll

    Query ,qsCities1State, would be:
    select * from table where [state]=forms!frmList!cboState

    the cboState uses qsStates query, user picks a state. In the cboState AFTERUPDATE event, use the code to change the query on the City cbo.
    Code:
    sub cboState_afterupdate()
      cboCity = null          'clear prev entry
      if isNull(cboState) then
              cboCity.rowsource = "qsCitiesAll"
              me.filterOn = false
      else
              cboCity.rowsource = "qsCity1State"              'filter the combo box with cities from that 1 state
              me.filter = "[State]='" & cboState & "'"          'filter the continuous form with 1 state items
               me.filterOn = true
         endif
    end sub
    when the user picks from the cboCity combo, then filter items further
    Code:
    sub cboCity_afterupdate()
       me.filter = "[State]='" & cboState & "' and [city]='" & cboCity & "'"
              me.filterOn = true
    end sub
    Now when user picks an item from the list to see the detail of a single person. frmDetail.
    this can load if the user picks an item from the list and wants to seem more detail...
    docmd.openform "frmDetail",,,"[id]=" & me.ID

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

Similar Threads

  1. Filter By Form and Apply Filter Buttons
    By JustLearning in forum Forms
    Replies: 13
    Last Post: 02-18-2015, 01:01 PM
  2. Replies: 2
    Last Post: 02-25-2013, 10:47 AM
  3. Replies: 5
    Last Post: 02-07-2013, 12:21 PM
  4. Apply Filter similar to Field Filter
    By DatabaseIntern in forum Forms
    Replies: 1
    Last Post: 06-11-2012, 05:42 PM
  5. How to filter dates using an apply filter code.
    By Jgreenfield in forum Reports
    Replies: 4
    Last Post: 11-15-2011, 01:38 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