Reputation: 93
I am using a simple code to filter a sub-form that has a several thousand lines of items.
Private Sub LampSearch_Change()
Dim strfilter As String
Me.Refresh
strfilter = "[SalesText] like '*" & Me.LampSearch & "'"
Me.LampDataSheetSubForm.Form.Filter = strfilter
Me.LampDataSheetSubForm.Form.FilterOn = True
Me.LampSearch.SelStart = Nz(Len(Me.LampSearch), 0)
End Sub
This works, but it isn't quite doing what I want. The only way I can seem to describe what it is doing is "like" rather than "contains". So if I search say, LED, it will only find specifically "LED", not "LEDA19".
What do I need to change to get it to search for records that "contain" the string?
Upvotes: 1
Views: 14
Reputation: 55816
You need (both a leading and) a trailing star:
strfilter = "[SalesText] like '*" & Me.LampSearch & "*'"
Upvotes: 2