更新另一个Combobox后的Combox Requery

时间:2014-04-04 20:43:17

标签: vba ms-access combobox access-vba

我有两个组合框,一个用于区域,一个用于区域(cboRR和cboDD)。我想让cboDD组合框只显示所选区域中的区域。到目前为止我所尝试的是将一个AfterUpdate添加到cboRR中,其中包含一个包含所有RRDD组合的长IF语句,并且cboDD具有一个OnClick Requery。我已经尝试了各种组合,到目前为止没有任何工作。有没有想过为什么我不能让这个工作?

AfterUpdate的if语句是:

Public Sub AfterUpdate()
If cboRR = "03" Then
cboDD = "03" & ";" & "12" & ";" & "13" & ";" & "30" & ";" & "46" & ";" & "55" & ";" & "56" & ";" & "76" & ";" & "86" & ";" & "92" & ";" & "95"
Else
cboDD = " "
End If
If cboRR = "07" Then
cboDD = "07" & ";" & "17" & ";" & "20" & ";" & "27" & ";" & "32" & ";" & "33" & ";" & "36" & ";" & "40" & ";" & "44" & ";" & "45" & ";" & "49" & ";" & "64"
Else
cboDD = " "
End If
If cboRR = "10" Then
cboDD = "17"
Else
cboDD = " "
End If
If cboRR = "12" Then
cboDD = "12" & ";" & "97"
Else
cboDD = " "
End If
If cboRR = "13" Then
cboDD = "02" & ";" & "04" & ";" & "21" & ";" & "41" & ";" & "45" & ";" & "46"
End Sub

1 个答案:

答案 0 :(得分:-1)

创建一个表格,列出您的第一个组合框区域的所有可能选项。然后为您的区域创建第二个表,其中的列将使所有适用的区域由管道符号分隔,如| 01 | 02 |。然后创建一个查询,查看第一个组合中的值,条件设置为:

Like "*|" & [Forms]![YourForm]![MyFirstComboBox] & "|*"