MS Access Forms:如何在组合框中动态更改选择选项? [英] MS Access Forms : How to dynamically change the select options in a combo box?

查看:128
本文介绍了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

这篇关于MS Access Forms:如何在组合框中动态更改选择选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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