Thread: Filter listbox with combobox
06-11-13, 06:03 #1Registered User
- 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.
06-11-13, 06:36 #2Jaded Developer
Provided Answers: 59
- Join Date
- Nov 2004
- out on a limb
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>" default WhereClause = "" end case myotherlistbox.rowsource = "Select my, column, list from mytable " & WhereClause & " order by another,column,list" myotherlistbox.requery 'might be .refreshI'd rather be riding on the Tiger 800 or the Norton