I have 3 List Boxes. Manub (Manufacturer), Segub (Seg) and (ListModu) Model.
I need for the user to select one or more in Manub to populate Segub, then pick one or more in Segub to populate ListModu, the to a query to give the data based on those choices.
I have Manub to Segub working, but can't get ListModu to populate with the records that match Manuf and Segub. It only returns the Model with the last Segub clicked instead of all of the ones highlighted...it's not returning multiples...it's showing one or more chosen, but only returning the last one clicked.
This is my code so far:
Code:
Private Sub Manub_AfterUpdate()
Dim varItm As Variant
Dim strWhere As String
If Me.Manub.ItemsSelected.Count = 0 Then
Me.Manub.SetFocus
MsgBox "Please select one or more manufacturers!", vbExclamation
Exit Sub
End If
For Each varItm In Me.Manub.ItemsSelected
strWhere = strWhere & " OR [dbo_BAMVtbl].[Manufacturer]=" & _
Chr(34) & Me.Manub.Column(0, varItm) & Chr(34) & _
" AND [dbo_BAMVtbl].[Manufacturer]=" & _
Chr(34) & Me.Manub.Column(0, varItm) & Chr(34)
Next varItm
Me.Segub.RowSource = "SELECT DISTINCT [dbo_BAMVtbl].[SEG] " & _
"FROM dbo_BAMVtbl WHERE " & Mid(strWhere, 4) & " ORDER BY seg"
End Sub
Private Sub Command45_Click()
Dim varItm As Variant
Dim strWhere As String
If Me.Manub.ItemsSelected.Count = 0 Then
Me.Manub.SetFocus
MsgBox "Please select one or more manufacturers!", vbExclamation
Exit Sub
End If
If Me.Segub.ListIndex = -1 Then
Me.Segub.SetFocus
MsgBox "Please select a seg !", vbExclamation
Exit Sub
End If
For Each varItm In Me.Manub.ItemsSelected
strWhere = strWhere & " OR [dbo_BAMVtbl].[Manufacturer]=" & _
Chr(34) & Me.Manub.Column(0, varItm) & Chr(34)
Next varItm
strWhere = "(" & Mid(strWhere, 4) & ") AND [dbo_BAMVtbl].[Seg]=" & _
Chr(34) & Me.Segub.Column(0) & Chr(34)
Me.ListModu.RowSource = "SELECT DISTINCT [dbo_BAMVtbl].[Model] " & _
"FROM dbo_BAMVtbl WHERE " & strWhere & " ORDER BY Model"