Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2013

    Unanswered: Filter listbox with combobox


    I'm prety new to access and VBA although I've maneged to build a prety simple database. I have few tabels and querys and forms.

    I have one form for employees, wich I select through listbox. When I click on a person in listbox I can then enter data about them in textbox, like Name,Surname, Address, Postal code, etc,...
    For each person I also must define if it is a regular worker, temporar worker or student and for that there are checkboxes.
    Now I would like to have a combobox where I would select lets say STUDENT and in listbox I would only see persons marked as student. Same for REGULAR and TEMPORAR. And for last there would be option ALL.

    Can please someone help me with that problem. I would really apriciate and I would be very thankfull.

  2. #2
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    so effectively you want to change the the contents of a listbox based on values in another list box.

    create your new list box
    provide the 4 types you want (ALL, STUDENT, REGULAR & TEMP)
    then in that list box's on click event place soem code that applies the appropriate filter

    dim WhereClause as string
    select case mylistbox.text
    case = "STUDENT"
      WhereClause = " WHERE EmploymentType = <insert whatever value you need>"
    case = "REGULAR"
      WhereClause = " WHERE EmploymentType = <insert whatever value you need>"
    Case = "TEMPORARY"
      WhereClause = " WHERE EmploymentType = <insert whatever value you need>"
      WhereClause = ""
    end case
    myotherlistbox.rowsource = "Select my, column, list from mytable " & WhereClause & " order by another,column,list"
    myotherlistbox.requery 'might be .refresh
    you'd need to replace the my listbox,myotherlistbox,my,column,list etc with your own values
    I'd rather be riding on the Tiger 800 or the Norton

Tags for this Thread

Posting Permissions

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