2 Combo Boxes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Access 2000

I have a combo box called CboTrng that has 10 items in it. Based on the
users selection I would like to have another combo box that provides options
specific to their selection. Each item from the 1st combo box has its own
sub-options there are no duplicates.

Is there a way to have the second combo box appear when they select
something from the 1st box that has sub-options?
 
Please note, this is asked and answered all the time. In the future, I'd
suggest you search for your answers before posting a new thread. You could
also look at the examples of this functionality in the sample database
(Northwind) that ships with Access. The easiest way I have found is to go
to www.google.com, click the "groups" options, and enter a search string
starting with the following...

microsoft.public.access cascading combo
 
Access 2000

I have a combo box called CboTrng that has 10 items in it. Based on the
users selection I would like to have another combo box that provides options
specific to their selection. Each item from the 1st combo box has its own
sub-options there are no duplicates.

Is there a way to have the second combo box appear when they select
something from the 1st box that has sub-options?

Leave the 2nd combo box row source blank.

Code the 1st Combo Box afterupdate event something like this
(substitute your own table and field names:

Combo2.RowSource = "Select TableName.[FieldName] From TableName Where
TableName.[FieldName] = " & Me!CboTrng


The above assumes the bound column of cboTrng is a Number datatype.
If it is text datatype use:
Where TableName.[FieldName] = '" & Me!CboTrng & "';"
 
If you want to make combo2 visible base on the selection of combo1 then on
the after update event of combo1 write the code

Select case Me.Combo1Name
case 1,2,3,4
me.combo2.visible = true
case 5,6,7,8
me.combo2.visible = False
End Select

To limit the llist of combo2, aplying a filter from combo1, create a
reference in the row source of combo2 to combo1

Select Field1, Field2 From TableName Where FieldName =
Forms![FormName]![Combo1name]
On the after update event of combo1 write the code
Me.Combo2.Requery
 
Back
Top