Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
167 views
in Technique[技术] by (71.8m points)

ms access - How can i filter a combobox selection list based on another combobox selection

I'm sure this question may have been asked to death, but I cant find 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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...