Solved

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

Posted on 2013-01-19
3
289 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
corrupt Databases 9 65
Microsoft Access Dcount --   check if  field has a valid date 5 33
Access Schema 6 26
XML Node Counting in MS Access VBA 4 35
Many companies are making the switch from Microsoft to Google Apps (https://www.google.com/work/apps/business/). Use this article to learn more about what Google Apps has to offer and to help if you’re planning on migrating to Google Apps. It is …
Article by: Leon
Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

860 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