Filtering Combo List on Previos Selections

  • Thread starter Thread starter Stewart Mashiter
  • Start date Start date
S

Stewart Mashiter

(Within a Table)

Does anyone know how I can filter a combo list on one
field by selecting an option of another combo list.

For instance:

If combo list 1 is a selction between biscuits and sweets
and I change the list in combo list 2 to relevant
selections.

For instance:

If I selected 'sweets' (Combo list 1), I want a list
(combo box 2) showing

Boiled
Chewy
Chocolate

However, if I selectd 'buscuits' (Combo box 1), I want a
list (combo box 2) showing

Digestive
Rich Tea
Bourbon
Custard Cream


All help very much appreciated.
 
Something like the following.

Public Sub cboCombo1_AfterUpdate()
Dim strRowsource As String

Select Case cboCombo1
Case "Sweets"
strRowsource = < see Note>
' Example (if cboCombo2.RowSourceType = ValueList):
' strRowsource = "'Boiled'; 'Chewy'; 'Chocolate'"
Case "Biscuits"
strRowsource = < see Note>
End Select
Me.cboCombo2.RowSource = strRowsource
End Sub

Note:
- If RowSourceType of cboCombo2 is ValueList then strRowsource should be a
semicolon delimited list.
- If RowSourceType of cboCombo2 is Table/Query or FieldList then
strRowsource should be either a SQL statement or the name of a query/table.

Hope this helps,
 
Back
Top