f



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
0
troy_lee (92)
5/22/2008 1:32:34 PM
comp.databases.ms-access 42670 articles. 0 followers. Post Follow

6 Replies
596 Views

Similar Articles

[PageSpeed] 20

troy_lee@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
	
0
oil (4047)
5/22/2008 2:14:18 PM
On May 22, 10:14 am, Salad <o...@vinegar.com> wrote:
> 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
0
troy_lee (92)
5/22/2008 3:07:25 PM
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.

0
5/22/2008 3:39:59 PM
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
0
5/22/2008 3:51:47 PM
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.)
0
troy_lee (92)
5/22/2008 4:13:35 PM
A usability suggestion would be to disable the 2nd combo box until something
is selected from the 1st.

<troy_lee@comcast.net> wrote in message
news:630e4fd2-41ba-43ae-afe4-466af71a585a@27g2000hsf.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.)


0
none9565 (357)
5/22/2008 8:00:06 PM
Reply:

Similar Artilces:

Fill combo/list box based on previous combo box selection?
I am fairly new to database design and am having some difficulty getting my combo boxes to work as I'd like them to. I would like to create a form with two combo boxes; the first one would select �JobNum' from my master job table and the second would select a �Supt' associated with the selected JobNum. My tables are setup like this: -tblEmp: Emp# (PRIMARY KEY), EmpName, etc. -tblSupt: SuptEmp#, Job# -tblInjury: InjuredEmp#, Job#, Supt#, etc. -tblJob: Job# (PRIMARY KEY), JobName, etc. How can I setup my two combo boxes so that: Combo Box 1 selects Job# from the list of Job#'s? I can get this far, but a can't seem to tackle the AfterUpdate event in order to successfully populate the 2nd combo box. And Combo Box 2 selects an associated Supt#, a list populated from the selection in Combo Box 1? Thanks in advance for any assistance. Nick Nick, If I understand you right, you want to select a Job# and have the second combo box update to show Supt#'s for the selected Job#. This is what I would do. This is done using a form. Since you have the Job# combo box working let's look at the Supt# combo. Create the Supt# combo like normal. Then go to the properties of the Supt# combo and go to the data tab. Then goto row source and click the build button. From here you can add the Job# field from your tblSupt to the design grid and set the criteria to the Job# combo box on your form. This will tell t...

How to reference one combo box from another combo box
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 function build, but im missing the how to reference one combobox from another combobox. I've tried using the getElementById with no success. This is how the form with the 2 combobox looks like: <form> <select name="cars" size="1" onchange="addColor(???)"> <option value="Volvo">Volvo</option> <option value="...

Update combo box when another combo box onchange event
Hi I'm just trying to use access for the first time. I have used mysql befor so I know i little about datebases. I have imported some tables into access and i have some querys too. Now I want to use one of the query to update a combobox whem I select an option in anoyher combobox. I can run the query but how do I get the result into the combobox? And how do I update it? If someone will answer Thanks in advance *** Sent via Developersdex http://www.developersdex.com *** On 24 Mar, 10:00, kalle <ka...@yahoo.com> wrote: > Hi > > I'm just trying to use access for the first time. I have used mysql > befor so I know i little about datebases. > > I have imported some tables into access and i have some querys too. Now > I want to use one of the query to update a combobox whem I select an > option in anoyher combobox. > > I can run the query but how do I get the result into the combobox? And > how do I update it? > > If someone will answer You need to use the AfterUpdate or the OnChange event of the first combo box, use whatever values you need to construct the SQL, and then set the DataSource of the second combo box. Edward kalle wrote: > > Hi > > I'm just trying to use access for the first time. I have used mysql > befor so I know i little about datebases. > > I have imported some tables into access and i have some querys too. Now > I want to use one of the query to update a combobox whem...

Combo box dependent on another combo box, text part is blank
Hi, I have a form with several combo boxes, continuous form format, with record source a query off an Item Table. The fields are Category, Subcategory, and Color. I am displaying descriptions, not ID's, so I have to convert the ID's from various lookup tables. The combo boxes work fine except for subcategory, which is dependent on category. Depending on category, the drop-down box for subcategory will display different items. (for example, when Category is Furniture, Subcategory will display drop-down list of 'Dresser, Nightstand, Desk...". Without clicking on the drop...

Fill text box based on combo box selection
Okay this one has me stumped. I have a table called Review_Statements with the following columns: statementid type statement1 statement2 statement3 I have a form called SR_Review with an unbound combo box control (rationale_type) that is based on the statementid and type field of the table above. I also have another text box control on the same SR_Review form called rationale. This field is bound to field called "rationale" in another table called SR_Reviews. Here is what I *want* to take place. The user makes a selection in the rationale_type combo box, and based on the statemen...

Populating text box based on combo box selections
I have a form that contains two combo boxes that are related to each other. I need to find a way to populate my text box based on the criteria of the two combo boxes so the appropriate number appears in the text box. "SHAWTY721" <u38136@uwe> wrote > I have a form that contains two combo boxes that > are related to each other. I need to find a way to > populate my text box based on the criteria of the two > combo boxes so the appropriate number appears in > the text box. It's just not possible to be very helpful with the information you provided (Whi...

selecting list box entry using a combo box
I have a combo box that lists street numbers. I also have a list box that lists street numbers and addresses (separately). I want to click on one of the street numbers and have the first item in the list box with that street number selected. Any suggestions will be appreciated. Deborah Hi Deborah, Not going to ask you “why use a listbox?”. But here goes… Use this air code in you combo box afterupdate event. Assuming both control in the same form. Me.ListBoxName.RowSource = “SELECT StreetNumber, Addresses,…..FROM Table1 Where StreetNumber = “ & Me.ComboxName I’m assuming your Stre...

How to change the contents of a combo box based on another
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 combo box where I can select a continent from a continent table. I would like the contents of a second combo box to reflect my choice of continent and list countries that are in that continent. These countries are in separate tables/queries (actually a query based on the table that orders the countries alphabetically). The database contains the following tables/queries Continent Table: SOURCE OF F...

Basing a Field list on another combo box
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 help me with this? Thanks for your time and cooperation. Louly If I've understood what you want (show the list of fields that are in a selected query), use the AfterUpdate event fo the list of queries: Private Sub cboQuery_AfterUpdate() Me.cboField.RowSource = Me.lboQuery End Sub cboQuery is the list of queries. cboField is the list of fields in the ...

Multiple Combo Boxes as well as multiple Multi select List Boxes to report
How would i print a report based on criteria selected from several Combo Boxes as well as multiple Multi Select List Boxes, that are located on the same form? I can get one Multi List Box, just not several, to report using this code i found - Private Sub cmdPreview_Click() On Error GoTo Err_Handler Dim varItem As Variant 'Selected items Dim strWhere As String 'String to use as WhereCondition Dim strDescrip As String 'Description of WhereCondition Dim lngLen As Long 'Length of string Dim strDelim As String 'Delimiter for this field type. Dim strDoc As String 'Name of report to open. 'strDelim = """" 'Delimiter appropriate to field type. See note 1. strDoc = "Products by Category" With Me.lstCategory For Each varItem In .ItemsSelected If Not IsNull(varItem) Then strWhere = strWhere & strDelim & .ItemData(varItem) & strDelim & "," 'Build up the description from the text in the visible column. See note 2. strDescrip = strDescrip & """" & .Column(1, varItem) & """, " End If Next End With lngLen = Len(strWhere) - 1 If lngLen > 0 Then strWhere = "[CategoryID] IN (" & Left$(strWhere, lngLen) & ")"...

Access 2003 post SP3 hotfix
"Combo box controls and list box controls display no value or incorrect values in Access 2003 after you install Office 2003 Service Pack 3." And a few more problems SP3 introduced. Description of the Access 2003 post-Service Pack 3 hotfix package: December 18, 2007 http://support.microsoft.com/kb/945674 Tony -- Tony Toews, Microsoft Access MVP Please respond only in the newsgroups so that others can read the entire thread of messages. Microsoft Access Links, Hints, Tips & Accounting Systems at http://www.granite.ab.ca/accsmstr.htm Tony's Microsoft Access Blog...

value in list box or combo box
i would like to use combobox or list box in a form for data entry do i have to have a table with value in it and the combobox or list box should look in to that table or i type in the values. 'cause when i create a form with text box and change it to combobox the box is empty there are no records in it . On Apr 12, 10:29 am, "access baby" <nishkr...@gmail.com> wrote: > i would like to use combobox or list box in a form for data entry do i > have to have a table with value in it and the combobox or list box > should look in to that table or i type in the values. &...

How to access a combo box value by providing the selection string from another vi.
Hi, &nbsp; I have a lower level communication vi with a combo box.&nbsp; I'm using the strings&amp;values[] property to initialize the combo box.&nbsp; When I select a string from the dropdown I get the corresponding value but when I pass in the same string from a caller vi I don't get the corresponding value.&nbsp; How can I access the value for the item I'm selecting from outside?? Perhaps you should just use the strings &amp; values property node to them out of the combo box, then search the 1-D array of clusters for the string that matches the one you are looking for, then return the corresponding value.&nbsp; Since it sounds like you are trying to access the control programmatically, use the programmatic features that are available. &nbsp; Maybe I'm mistaken in what you are trying to do, in which case please post some representative VI's. Thanks Ravens Fan, &nbsp; I did what you suggested.&nbsp; Looking at the text string property and&nbsp;searching the array for the correct value pair seems to work.&nbsp;&nbsp;I thought there was an easier way to access the values directly but this works too. What Rob described is exactly the behavior I was observing in my vi.&nbsp; It is good to know this type of information since&nbsp;I'm an experience programmer but new to Labview and I'm not aware of this kind of behavior.&nbsp; Also thanks for the enum tip.&nbsp; It's kind of frus...

Listbox based on text box and combo box.
On an unbound form, I have a combobox called 'cboproducttype' and a text box called 'txtamountappliedfor'. I have an Add button that I would like the user to be able to hit once a product and amount applied for has been entered. This should populate an unbound listbox to display their selections. A user can select one or more sets of product types and the amount applied for. They should also have the functionality to remove a 'set' if they made a mistake without the need to rebuild the whole listbox of selections. Then - I want to loop through the listbox of select...

Populate text boxes with combo box selection
I need to populate text boxes for instance with employee information using their unique employee works number selected from a combo box. Can anyone help, I am told thru visual basic this can be achieved. godber wrote: > I need to populate text boxes for instance with employee information > using their unique employee works number selected from a combo box. > Can anyone help, I am told thru visual basic this can be achieved. You can do it without VBA. Add extra columns to the combo box Set the width of the columns to 0 if you want to hide them In the text bnoxes you want to show the...

Filter List Box using Combo Box on a form
I've read some posts similar to this, but the SQL does not seem to have the desired effect in my form. I'm trying to filter a list box (lstOfficeClass) using a combo box (cbxProfitCenter). The list box rowsource is a table (OfficeClasses) that contains all the text fields "OfficeClass". The table also has corresponding text fields "ProfitCenter". I've entered the following into the AfterUpdate event for the combo box: strsql = "SELECT OfficeClasses.OfficeClass FROM OfficeClasses ORDER BY OfficeClasses.OfficeClass WHERE OfficeClasses.ProfitCenter = " & cbxProfitCenter lstOfficeClass.RowSource = strsql When opening the form, all OfficeClass fields show as expected. After selecting a ProfitCenter in cbxProfitCenter, the list box goes blank. Thoughts? Generally it's easier to have the listbox reference the combobox from the outset. After you update the combobox requery the listbox. As has been discussed recently you can have the listbox criteria use a "like" statement and, via a union query, put an "*" in the listbox options. Good luck Tim Mills-Groninger On Jul 15, 9:31=A0am, pthe...@hotmail.com wrote: > I've read some posts similar to this, but the SQL does not seem to > have the desired effect in my form. > > I'm trying to filter a list box (lstOfficeClass) using a combo box > (cbxProfitCenter). =A0The list box rowsource is a table (OfficeClasses) > that contains all t...

select of select box will select multiple in another box
Im trying to do the following: I have 2 select boxes, both are pre populated with data. The first box is a single select box, the 2nd is a multiple select box. Depending on the 1st selection, I want to have multiple values in the second select box highlighted. ie box 1 <select name=type> <option> warm colors <option> cool colors <option> shades of grey </select> box 2 <select name=colors multiple> <option> red <option> orange <option> yellow <option> blue <option> green </select> If the user would selec...

Setting the size of column widths of a combo box through Code and Searching Combo Box
I have a combo box on a form which is based on table tblMachine. On that combo box I have four columns visible MachineNumber, description, location and type. The bound column is the MachineNumber and this is not set to 0 as the machines have its number on which means the user should know the machine number. My problem is if the user doesn't know the number. I have a button which changes the row source of the combo box to order by description, but when the user starts to type the description the relevant record does not come up as machine number is still visible. Is it possible, when I...

How to change the properties of Text box depending on the value of combo box.
Hi, I have created a combo box with "", Yes,No so that if user select any other option except Yes the text box should become disabled. For this I have written code in the exit event of the combo box it is working . But the problem is that, after reopening the form, if you navigate to same record it shows the check box enabled. Can anyone help me how to solve the problem. thanks Pervaiz Try using the same code in the 'On Current' event for the form. At present your code works ony if you exit the combo box, so when you open the form it won't run. With the 'On Curr...

Access 2007 combo box change event
Using Access 2007 Windows XP I have a form with, among other things, two combo boxes. The form and both combo boxes are unbound. I have code running in the change event of the first combo box that updates the RowSource property of the second combo box to something like: "SELECT Field2 FROM TableA WHERE Field1 = " & Forms!FormName! FirstComboBox.Value & " ORDER BY Field2 ASC;" A client recently reported a bug in that the data in the second combo box is not loading properly, using Access 2007. This cannot be duplicated in either Access 2000 or 2003. When the form is first opened, if the tab order is used to navigate to the first combo box the code running on the change event shows the Value and Column(0) properties as null, and the expected value for the Text property. Once the second combo box has the focus, the Value, Column(0) and Text properties of the first combo box all contain the expected values. However, if the mouse is used to navigate to the first combo box, the Change event then shows the correct values in all three properties. I'm unable to find any documentation of this behavior here or elsewhere. Is this a bug? A change in the behavior of a combo box? ...

Limiting items in combo boxes based on another
Does anyone have experience with limiting items in one combo box based on the selected item in another? I figured out how to do it, but now I need to complete the hierarchy I am building and link 2 additional combo boxes. I am a new Access user. My problem is the third combo box cboJobRole. It does not display any items, and does not appear to be limited by the second combo box cbocareerband. My first combo box sql is: SELECT [Career Families].[Career Family], [Career Families].DropDownType FROM [Career Families] ORDER BY [Career Families].[Career Family]; My second combo box sql is: ...

Referencing a toolbar combo box in MS Access
Is there a way to determine the value of a combobox that resides in a toolbar other than using CommandBars.ActionControl? I want a user to be able to change the combobox and be able to refer to the selected value later, not immediately, and without having to set a public variable. This refers to the toolbar when adding a combobox to the toolbar: CommandBars("myToolbarName").Controls.Add(Type:=msoControlComboBox) But what referes to the combobox once it's created? Any help is appreciated. LQ I found a way to do this for anyone who had the same question: '***START CODE*** Dim objBar As CommandBar, objCbo As CommandBarComboBox, myIndex As Integer Set objBar = Application.CommandBars("myToolbarName") Set objCbo = objBar.Controls("myComboName") myIndex = objCbo.ListIndex Set objCbo = Nothing Set objBar = Nothing '***END CODE*** laurenquantrell@hotmail.com (Lauren Quantrell) wrote in message news:<47e5bd72.0309040455.2143a9a2@posting.google.com>... > Is there a way to determine the value of a combobox that resides in a > toolbar other than using CommandBars.ActionControl? I want a user to > be able to change the combobox and be able to refer to the selected > value later, not immediately, and without having to set a public > variable. > This refers to the toolbar when adding a combobox to the toolbar: > CommandBars("myToolbarName").Controls.Add(Type:=msoControlComboBo...

Unbound combo box: I can't select an item in the box
I have a strange problem. When I put a combo box into a form, and set a row source, when I display the form I can pull down the list of items, but when I select an item it does nothing. It doesn't call the event handler it doesn't select the item into the combo box: nothing. The combo box is unbound. I didn't change the properties of the combo, just the default ones the control wizard supplies. I think I have done this many times before, but this is the first time I tried with Access 2002, am I doing something really dumb? And if so, what can I do to fix this problem? Thanks. &q...

Select records based on three different combo boxes
How can you select records based on more than one combo box - I have a combobox that selects records based on name (I'm sure this has been asked a thousand times - web site answer/link could be helpful too; but I'm so bad with syntax that specifics will be MOST helpful) SELECT DISTINCT [qryAE_ProtocolsSponsors].[PI Last Name], [qryAE_ProtocolsSponsors].[PI First Name] FROM [qryAE_ProtocolsSponsors] Union Select "<ALL>" , NULL From [qryAE_ProtocolsSponsors]; and sorts the results: If Me![Combo24] = "<All>" Then DoCmd.ShowAllRecords Me.Order...

Web resources about - Changing combo box list based on another combo box selection - comp.databases.ms-access

Selection - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

World T20: Khawaja, Finch in selection battle - DailyTelegraph Search Search
UPDATE: AARON Finch appears in the box seat to hold off a strong challenge from Usman Khawaja and open for Australia at the World Twenty20.

World T20: Khawaja, Finch in selection battle
UPDATE: AARON Finch appears in the box seat to hold off a strong challenge from Usman Khawaja and open for Australia at the World Twenty20.

Wilson wins selection in Goldstein
Frm Human Rights Commissioner Tim Wilson has been selected as the Liberal candidate in the seat of Goldstein

March Madness: Selection Sunday has arrived
This year, Selection Sunday features five conference tournament championships before brackets are released.

Selection Sunday Has Wildcats, Owls, Hawks Fans Pumped
The NCAA college basketball selection committee has ruled, and three local teams are on the tournament bracket this March Madness.

How NCAA selection committee seeds March Madness tournament - Videos - CBS News
It is a big weekend for men’s college basketball. March Madness is about to begin, and the men’s basketball selection committee will announce ...

People Were FURIOUS The Selection Show Took Two Hours
People Were FURIOUS The Selection Show Took Two Hours

How Much Did The NCAA Selection Committee Screw Your Team Over?
In the long, drawn-out days between Selection Sunday and the beginning of the round of 64, college basketball fans have two pastimes: filling ...

Selection Sunday: Kansas Faces Hardest Path To National Title, While Michigan State Handed Easiest
It is difficult to imagine any team in this year's NCAA tournament field navigating through stronger headwinds than Kentucky encountered two ...

Resources last updated: 3/20/2016 4:37:23 PM