N
NYbills
I have a form that the recordsource is called from query. On this form I
also have a multiple select listbox. this has the following sql statement as
the row source
SELECT qryproductfamilydescription.[Product Family Description] FROM
qryproductfamilydescription
with the following code
Private Sub List200_AfterUpdate()
Dim cnt, i As Integer
Dim strFilter As String
'On Error GoTo Problem
' Filter this form based on list selection
cnt = 0
For i = 0 To Me.List200.ListCount - 1
If Me.List200.Selected(i) Then
If cnt = 0 Then
strFilter = "[Product Family Description] = '" & Me.List200.ItemData(i) &
"'"
Else
strFilter = strFilter & " OR [Product Family Description] = '" &
Me.List200.ItemData(i) & "'"
End If
Me.Filter = strFilter
Me.FilterOn = True
cnt = cnt + 1
End If
Next i
Exit Sub
Problem:
'Code below shows the error message
'MsgBox Err.Description, , "Error n°" & Err.Number
Err.Clear
End Sub
What I am trying to accomplish is when selecting all the records in the
listbox have them all filter to give me the same amount of records. There is
a limitation and I would like to know how to workaround. I am very new at
this and a step by step would be greatly appreciated.
also have a multiple select listbox. this has the following sql statement as
the row source
SELECT qryproductfamilydescription.[Product Family Description] FROM
qryproductfamilydescription
with the following code
Private Sub List200_AfterUpdate()
Dim cnt, i As Integer
Dim strFilter As String
'On Error GoTo Problem
' Filter this form based on list selection
cnt = 0
For i = 0 To Me.List200.ListCount - 1
If Me.List200.Selected(i) Then
If cnt = 0 Then
strFilter = "[Product Family Description] = '" & Me.List200.ItemData(i) &
"'"
Else
strFilter = strFilter & " OR [Product Family Description] = '" &
Me.List200.ItemData(i) & "'"
End If
Me.Filter = strFilter
Me.FilterOn = True
cnt = cnt + 1
End If
Next i
Exit Sub
Problem:
'Code below shows the error message
'MsgBox Err.Description, , "Error n°" & Err.Number
Err.Clear
End Sub
What I am trying to accomplish is when selecting all the records in the
listbox have them all filter to give me the same amount of records. There is
a limitation and I would like to know how to workaround. I am very new at
this and a step by step would be greatly appreciated.