Combo Box Selection to change List Box

  • Thread starter Thread starter DMc2004
  • Start date Start date
D

DMc2004

Hi

What I would like to do is when a value is selected in a Combo box a set of
values a change in another combo or list box.

how can I do this.

Many thanks

D
 
Hi

What I would like to do is when a value is selected in a Combo box a set of
values a change in another combo or list box.

how can I do this.

Many thanks

D

Sure.
Leave the ListBox Rowsource blank.

Code the Combo Box AfterUpdate event to load the list box:

ListboxName.RowSource = "Select TableName.* from TableName where
TableName.CompanyID = " & Me!ComboName

You've given no indication of what you need, so I'll leave it to you
to adapt the above generic code to your own needs.
 
To filter the dropdown list in one combo (or list) box (cmb2) based upon the
selection made in another combo (cmb1), you would put code in cmb1's
AfterUpdate eventHandler along the lines of
cmb2.RowSource = "SELECT myCol FROM MyTable WHERE filterCol = " & cmb1.Value
(if cmb1.Value is a number)
or
cmb2.RowSource = "SELECT myCol FROM MyTable WHERE filterCol = '" &
cmb1.Value & "'" (if cmb1.Value is a string)

If you wish to present a different Value List depeneding upon the selection,
the code would look something like
Select Case cmb1.Value
Case 1
cmb2.RowSource = "abc,def,ghi etc"
etc
End Select

Hope This Helps
Gerald Stanley MCSD
 
Back
Top