根据组合框选择过滤列表框 [英] Filtering a Listbox based on Combobox selection

查看:56
本文介绍了根据组合框选择过滤列表框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个表:Person和Shift

I have two tables: Person and Shift

人员具有与Shift一对多关系的查找字段.

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

我想创建一个表单,其中根据包含Shift记录的组合框的选择,对显示Person记录的列表框进行过滤.

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.

换句话说,我想在组合框中选择天"(值1),并且只在列表框中显示其Shift字段中值1的人"记录?

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?

等效的sql类似于:

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

此外,如果可能的话,我想用很少甚至没有VBA来做到这一点,因为我要传递给这个对象的人没有VBA经验,不能指望修复VBA代码中的错误.

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.

推荐答案

您所要做的就是在访问中使用查询生成器,并将条件设置为第一个组合框的值

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]

然后在第一个组合框的after update事件中

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

Me.Second_combo_box.Requery

这篇关于根据组合框选择过滤列表框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆