instr in a filter (2 Viewers)

John Sh

Active member
Local time
Today, 15:56
Joined
Feb 8, 2021
Messages
565
I have a list of names in a field "Collector" that can include the names of others in a team, .e.g. "Jones. K. Smith. W."
I want to filter this field such that it will return all fields that include "Jones" .
I have tried many variations of the code below but .filter always returns "False".
sFilter, in the example above will be "Jones"

Code:
.Filter = "[Collector]= " & InStr(.Collector, sFilter) """

if I use this code

Code:
.Filter = "[Collector]= '" & InStr(.Collector, sFilter) & "'"

.filter returns "[Collector] = '0'"
 
would think you would want

.Filter = "[Collector] like '*" & sFilter & "*'"
 
I would guess the OP is using ADO recordsets. Would have been helpful to know that
 
I would guess the OP is using ADO recordsets. Would have been helpful to know that
With an ADO recordset there is no need to use ALIKE but, yes, you would need the % wildcard.

My guess is that they have set ANSI compatible SQL in their db, but unsure without clarification. You can still use ALIKE without that 'feature' being set.
 
With an ADO recordset there is no need to use ALIKE but, yes, you would need the % wildcard.

My guess is that they have set ANSI compatible SQL in their db, but unsure without clarification. You can still use ALIKE without that 'feature' being set.
Correct. I set the ANSI compatible SQL some time ago as it simplifies "?" using SQL strings and doesn't affect stored queries.
Thank you all for you comments.
 

Users who are viewing this thread

Back
Top Bottom