简体   繁体   English

将条件从组合框传递到Access 2010中的另一个组合框

[英]Pass criteria from a combo box to another combo box in access 2010

I am trying restrict the records in combo box 2 (cboNames) based on the selection of combo box 1 (cboClass). 我正在尝试根据组合框1(cboClass)的选择来限制组合框2(cboNames)中的记录。

Combo box 1 and combo box 2 are both based on records in the same table, tblNames. 组合框1和组合框2都基于同一表tblNames中的记录。

Combo box 1's row source is set too 组合框1的行源也已设置

SELECT [tblNames].[ChildID], [tblNames].[Class] FROM tblNames;

Combo box 2's row source is set too: 组合框2的行源也已设置:

SELECT tblNames.ChildID, tblNames.[Full Name], tblNames.Class FROM tblNames WHERE (((tblNames.Class)=[Forms]![frmInsertNewRecord]![cboClass]));

I was under the impression this should work but it obviously inst. 我觉得这应该可行,但显然可以安装。 Combo box 2 is blank. 组合框2为空白。

Can anybody identify what i am doing wrong? 有人可以识别我在做什么吗?

Once the value of the first combo box changes, you need to refresh the recordset of the second one. 一旦第一个组合框的值更改,您需要刷新第二个组合框的记录集。

You need to either hit the refresh button ( F5 ) or add the following code in the _AfterUpdate event of the 1st box: 您需要点击刷新按钮( F5 )或在第一个框的_AfterUpdate事件中添加以下代码:

Private Sub cboClass_AfterUpdate() 
    Me.cboName.Requery
End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM