Solved

Make The Selections Available In ComboBox2 Dependant On The Value Of ComboBox1

Posted on 2013-01-19
3
288 Views
Last Modified: 2013-01-19
I have a series of combo boxes. I want to use VBA to change the values available in the second combo box, based on what was chosen in the first one.

I think the following code, (even though its non-working), shows what I am wanting to do:

Private Sub CboBox1_AfterUpdate()

If Me.CboBox1 = "Choice1" Then
Me.CboBox2.RowSource = "Result1";"Result2";"Result3"
ElseIf Me.CboBox1 = "Choice2" Then
Me.CboBox2.RowSource = "Result4";"Result5";"Result6"

End Sub

I have seen examples of combo boxes that do something similiar to what I am wanting to do, but they all used select statements - Is there a way to control the options available in a combo box purely with VBA?
0
Comment
Question by:Drizzt420
3 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 38796378
Set the rowsource type to value list


Me.combo.rowsourcetype = "value list"
Me.combo.rowsource = "'apples', 'oranges','bananas'"
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38796388
Select Case Me.CboBox1
    Case "Choice1"
        Me.CboBox2.RowSource = "Result1;Result2;Result3"
    Case "Choice2"
        Me.CboBox2.RowSource = "Result4;Result5;Result6"
End Select
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 38797387
I would advise against hard coding this.  Instead, put those option combinations in a table and use queries as the source for your combo boxes.

The second combo would have a source like

Select field2 from yournewtable
Where field1 = forms!yourformname.combo1
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This very simple solution applies to a narrow cross-section of the "needs to close" variety. In this case, the full message in Event Viewer was in applog, Event ID 1000: Faulting application iexplore.exe, version 8.0.6001.18702, faulting module …
Lync meeting or Lync conferencing is what many organizations would like to deploy to allow them save money. But companies are now giving up for various reasons, one of which is that they cannot join external meetings (non-federated company meetings)…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now