MS Access Forms:如何在组合框中动态更改选择选项?

问题描述:

我的MS Access窗体有两个组合框,c1c2.

My MS Access form has a two combo boxes, c1 and c2.

我需要c2中的select options进行动态更改. . .当我在c1中选择一个选项时.我怎样才能做到这一点 ?

I need the select options in c2 to change dynamically . . . when i select an option in c1. How can I do this ?

c1中的每个值与c2中的多个值匹配.因此,如果在c1中选择Mike,则c2应该仅提供与Mike相对应的那些选项.现在,combo box c2显示所有选项.

Each value in c1 matches multiple values in c2. So if I select Mike in c1, the c2 should provide only those options that correspond to Mike. Right now combo box c2 shows ALL options.

如何根据c1中选择的内容来限制c2中的选项?

How can I restrict the options in c2 based on what was selected in c1 ?

谢谢!!!

使用C1中的AfterUpdate事件并更新C2的rowSource 像这样:

use the AfterUpdate event from C1 and update the rowSource for C2 something like:

Private Sub c1_AfterUpdate()
    Dim iVal As String
    iVal = Nz(Me.c1.value, "")


    Dim S As String
    S = "SELECT Field from myTable where Field like '" & iVal & "'"
    Me.c2.RowSource = S
    'Optionally me.C2.Requery
End Sub