开发者

How can i filter a combobox selection list based on another combobox selection

开发者 https://www.devze.com 2023-01-25 09:44 出处:网络
I\'m sure this question may have been asked to death, but I cant find开发者_如何学JAVA any answer that i can get to work. Basically I would like to have two combobox controls. One box selects an armor

I'm sure this question may have been asked to death, but I cant find开发者_如何学JAVA any answer that i can get to work. Basically I would like to have two combobox controls. One box selects an armor type for example. The next box would show only those unit types that have the armor type selected. I'm complete crap when it comes to SQl and very limited with my VBA, but would prefer a response in VBA since I understand it better. Any help in this matter would be great. please and thank you


There are many ways to achieve this.

For example: In the first combo box implement an Event "On Change". Do some VBA coding in it to fill up the second combo box based on the value selected on the first combo box. See a VBA example below

There are tons of tutorials if you google for "access combo box based on another".

Private Sub Combo1_Change()

    If Me.Combo1.Value = "value1" Then
        Me.Combo2.RowSource = "val 1 based on 1;value 2 based on 1"
    End If

    If Me.Combo1.Value = "value2" Then
        Me.Combo2.RowSource = "val 1 based on 2;value 2 based on 2"
    End If
End Sub


This is a common question, and a search for "cascading combobox" will return a number of answers, for example, MS Knowledge base has How to synchronize two combo boxes on a form in Access 2002 or in Access 2003 and one from Stackoverflow : Is there a simple way of populating dropdown in this Access Database schema?

0

精彩评论

暂无评论...
验证码 换一张
取 消