Filtering problems

 Cindy -

I have a microsoft database access and I'm trying to filter some records. This is what I do:

1. I have a form for query purposes, in tha form I have also a combo box which I use to select the name of the employee

2. I have another button to filter the records selected in that combobox, but when filtering, sometimes for some specific names is bringin me on ly th records for that name and for other names is bringing me 3, 4 or 5 more names, why? Here is an example of my filter code, any help would be kindly appreciated. thanks

Private Sub cmdFilter_Click()

Dim strWHERE As String
Dim lngLen As Long
Const conJetDate = "\#mm\/dd\/yyyy\#"

If Not IsNull(Me.campofiltro5) Then
strWHERE = strWHERE & "([IDAutonumemp] Like ""*" & Me.campofiltro5 & "*"") AND "
End If

lngLen = Len(strWHERE) - 5
If lngLen <= 0 Then
MsgBox "You must filter any criteria", vbInformation, "No filter found."
strWHERE = Left$(strWHERE, lngLen)

Me.Filter = strWHERE
Me.FilterOn = True
End If
End Sub

2 replies

Registration date
Thursday January 28, 2010
Last seen
August 2, 2020
Well you are using "LIKE" statement, so I were to search for Straw, I would get Straw and Strawberry and any thing else that contain "S.T.R.A.W.". Could that be the reason ?
Hi again, umm do you know how to fix this issue

Thanks again
Thank you, I wasne't pretty sure at the beginning but I noticed about the "LIke" thanks now its fixed
Umm, sorry but how do you fix that?

Thank you