473,396 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Changing combo box list based on another combo box selection

I have a continuous form that has one combo box (cbo1) with the
selectable values of "Removal" and "Installation". I would like to
change another combo box (cbo2) value list based on the selection in
cbo1.

For example, when the user selects "Removal" from cbo1 I would like
the value list of cbo2 to be one set of values and when "Installation"
is selected in cbo1 I would like the value list of cbo2 to be a
different set of values.

Is this possible?

Thanks in advance.

Troy Lee
Jun 27 '08 #1
6 18392
tr******@comcast.net wrote:
I have a continuous form that has one combo box (cbo1) with the
selectable values of "Removal" and "Installation". I would like to
change another combo box (cbo2) value list based on the selection in
cbo1.

For example, when the user selects "Removal" from cbo1 I would like
the value list of cbo2 to be one set of values and when "Installation"
is selected in cbo1 I would like the value list of cbo2 to be a
different set of values.

Is this possible?

Thanks in advance.

Troy Lee
Sometimes cbo2's rowsoure might be
"Select fld from table where id = " & cbo1
In this case, in the AfterUpdate event of cbo1 you'd enter
Me.cbo2.Requery

You might have to change the rowsource in other cases
If me.cbo1 = "Install" then
Me.cbo2.rowsource = "Select fld from table1"
Else
Me.cbo2.rowsource = "Select fld from table2"
Endif

Shark Surfer
http://www.youtube.com/watch?v=6zc79UQj1hQ

Jun 27 '08 #2
On May 22, 10:14 am, Salad <o...@vinegar.comwrote:
troy_...@comcast.net wrote:
I have a continuous form that has one combo box (cbo1) with the
selectable values of "Removal" and "Installation". I would like to
change another combo box (cbo2) value list based on the selection in
cbo1.
For example, when the user selects "Removal" from cbo1 I would like
the value list of cbo2 to be one set of values and when "Installation"
is selected in cbo1 I would like the value list of cbo2 to be a
different set of values.
Is this possible?
Thanks in advance.
Troy Lee

Sometimes cbo2's rowsoure might be
"Select fld from table where id = " & cbo1
In this case, in the AfterUpdate event of cbo1 you'd enter
Me.cbo2.Requery

You might have to change the rowsource in other cases
If me.cbo1 = "Install" then
Me.cbo2.rowsource = "Select fld from table1"
Else
Me.cbo2.rowsource = "Select fld from table2"
Endif

Shark Surferhttp://www.youtube.com/watch?v=6zc79UQj1hQ
Salad,
Thanks for the input. Why the ambiguity? You say sometimes it might
require a requery and others I may have to use an If...Then statement.
Which method is best in your opinion?

Thanks.

Troy
Jun 27 '08 #3
Hello,

When you are changing the values of a combobox, you have to know how
to fill it in

- Inserting a list of values (manualy):
You have to set the RowSourceType first to "Value List", then insert
the values
Me.MyCombo.RowSourceType = "Value List"
Me.MyCombo.RowSource = "Item; Item2; Item3"

- Using a query (automatically):
You have to set the RowSourceType first to "Value List", then insert
the values
Me.MyCombo.RowSourceType = "Table/Query"
Me.MyCombo.RowSource = "SELECT Id FROM Customers" or
Me.MyCombo.RowSource = rsReg where rsReg is a recorsdet

Nice coding.

Jun 27 '08 #4
You could use too the Click event of the Combobox_1, so everytime you
pick an item the events trigers and you could profit to change the
combobox_2

Private Sub Combobox1_Click()
if me.Combobox1.value = ucase("install") then

me.Combobox2.rowsource = "Item1; Item2" 'Presetting RowSource
= "Value List"
or
me.Combobox2.rowsource = "SELECT ..." 'Presetting RowSource =
"Table/Query"
or
me.Combobox2.rowsource = rsRecordset 'Presetting RowSource =
"Table/Query"

else
...
endif

:-)

End Sub
Jun 27 '08 #5
Nice work guys. I combined the suggestions of you both and it works
beautifully. Thanks for the great input.

BTW, for anyone else interested, this is the code for the solution.

In the After_Update Event of cbo1:

Private Sub cboReworkActivity_AfterUpdate()

If Me.cboReworkActivity = "Removal" Then
Me.txtNewXmtrStatus.RowSourceType = "Value List"
Me.txtNewXmtrStatus.RowSource = "In Cleanroom; Out of
Cleanroom"
Else
Me.txtNewXmtrStatus.RowSourceType = "Value List"
Me.txtNewXmtrStatus.RowSource = "New Xmtr.; Stock Xmtr.;
Original Reworked Xmtr."
End If

End Sub

(Note that txtNewXmtrStatus is really a combo box.)
Jun 27 '08 #6
A usability suggestion would be to disable the 2nd combo box until something
is selected from the 1st.

<tr******@comcast.netwrote in message
news:63**********************************@27g2000h sf.googlegroups.com...
Nice work guys. I combined the suggestions of you both and it works
beautifully. Thanks for the great input.

BTW, for anyone else interested, this is the code for the solution.

In the After_Update Event of cbo1:

Private Sub cboReworkActivity_AfterUpdate()

If Me.cboReworkActivity = "Removal" Then
Me.txtNewXmtrStatus.RowSourceType = "Value List"
Me.txtNewXmtrStatus.RowSource = "In Cleanroom; Out of
Cleanroom"
Else
Me.txtNewXmtrStatus.RowSourceType = "Value List"
Me.txtNewXmtrStatus.RowSource = "New Xmtr.; Stock Xmtr.;
Original Reworked Xmtr."
End If

End Sub

(Note that txtNewXmtrStatus is really a combo box.)

Jun 27 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: D | last post by:
Book inventory. Access 2K. I'm trying to let a user choose a book title from one combo box, then a book number for that book title from another combo box. I can filter the book number combo with...
2
by: Jeff Barry | last post by:
Hi, I wonder if any one can help, I'm pretty new to Access and I can't figure out how to change the contents of a combo box based on a selection I make in another. Let me explain I have a...
1
by: Cassie Pennington | last post by:
I have tried to filter one combo box based on a selection in another combo box, by using the following sample code: tblfield=forms!!. However, the combobox only seems to recognise the first...
1
by: Louly | last post by:
Hi everybody, In a form I have 2 combo boxes, X's Row Source Type is a "Filed list" and Y is based on a "Query". I wan to base X's drop down list on what's selected from Y's list. Can anyone...
11
by: abctech | last post by:
Hi, I am developing a webapplication using Javascript,JSP,Servlets. I have 2 dropdown lists in my form, the first one is autopopulated on form load , I have written this code in Jsp and its...
4
Rabbit
by: Rabbit | last post by:
Cascading Combo/List Boxes This tutorial is to guide you in the creation of Cascading combo/list boxes. That is when you have multiple combo/list boxes where the selection of an option in one...
3
by: joseph.mccastlain | last post by:
Hello All, I am a new user to Access. I am currently designing a database consisting of four tables for multiple users. Rather than bore you with the goals and such, here is what I am...
2
by: SM | last post by:
Hello, I have an HTML file that contains a form with 2 selection list (combo box). The first combobox 'onchange' function, addColor(),adds a new color to the second combobox. I have half of the...
8
by: NJonge01 | last post by:
Great thanks to all the helpful responses I've read! Recently using MS Access after a lengthy (7-10 years) away from the tool. I apologize for posting a question that for all intents & purposes...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.