Filtering a Listbox based on Combobox selection

梦想与她 提交于 2019-12-10 22:05:02

问题


I have two tables: Person and Shift

Person has as lookup field which is a one to many relationship with Shift.

I would like to create a form in which a listbox displaying records from Person is filtered based on the selection of a combobox containing the records from Shift.

in other words, i want to select "days" (value 1) in the combobox, and have only the records from Person that have value 1 in their Shift field displayed in the listbox?

the equivalent sql would be something like:

SELECT * FROM Person WHERE Person.Shift = (the value of the combobox here)

Also, if possible, i would like to do this with little to no VBA as the person i'm passing this off to has no VBA experience and can't be expected to fix bugs in the VBA code.


回答1:


All you have to do is use the query builder in access and set the criteria to the value of the first combo box

[Forms]![frmMy_form]![cboFirst_combo_box]

Then in the after update event of the first combo box just put

Me.Second_combo_box.Requery


来源:https://stackoverflow.com/questions/2871155/filtering-a-listbox-based-on-combobox-selection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!