Hi Guys,
I have used the following code to create a filter to find information on suppliers based on 3 criteria, postcode, waste type and container. I have the output textboxes set to show the supplier and contacts. I have also changed the combobox to allow extended selections which allows a search for suppliers with all those criteria. But at the moment the output lists the supplier multiple times to correspond to the selected waste criteria, ie I get a supplier in the output 4 times for each waste type. I would like to create a filter of the filter that only outputs the supplier once if it supplies the chosen criteria. Is it possible to do this??? Thank you!VB
I have used the following code to create a filter to find information on suppliers based on 3 criteria, postcode, waste type and container. I have the output textboxes set to show the supplier and contacts. I have also changed the combobox to allow extended selections which allows a search for suppliers with all those criteria. But at the moment the output lists the supplier multiple times to correspond to the selected waste criteria, ie I get a supplier in the output 4 times for each waste type. I would like to create a filter of the filter that only outputs the supplier once if it supplies the chosen criteria. Is it possible to do this??? Thank you!VB
Code:
Private Sub cmdFilter_Click()
Dim strwhere As String
Dim lngLen As Long
If Not IsNull(Me.SearchPostcode) Then
strwhere = strwhere & "([ser_postal]=""" & Me.SearchPostcode & """) AND "
End If
If Not IsNull(Me.SearchWasteType) Then
strwhere = strwhere & "([ser_wastetype]=""" & Me.SearchWasteType & """) AND "
End If
If Not IsNull(Me.SearchContainer) Then
strwhere = strwhere & "([ser_cont]=""" & Me.SearchContainer & """) AND "
End If
MsgBox strwhere
lngLen = Len(strwhere) - 5
If lngLen <= 0 Then
MsgBox "no criteria", vbInformation, "Nothing to do."
Else
strwhere = Left$(strwhere, lngLen)
Me.Filter = strwhere
Me.FilterOn = True
End If
End Sub