Taming the wildcards on filter form (1 Viewer)

ttomw

Registered User.
Local time
Today, 00:18
Joined
Apr 13, 2012
Messages
26
I have a form that accepts user input to create a filtered subset of data.

Two of the fields, Owner and PropClass, are set up to use wildcards, "*", for text strings. Right now if I enter sa* in the owner search field because I want to find owners whose last names begin with sa such as Sanchez or Sanderson I end up with all owners who have sa anywhere in their name such as Jensen Sara or KAI USA LTD.

I want it to evaluate values from the left of the field so that in the example above it only returns records that start with sa. I should have to input *sa* to return records where sa shows up anywhere in the field.

Following is an excerpt of the code that builds up the criteria string for these two fields:
DoCmd.SetWarnings False
DoCmd.RunSQL "Delete * from OwnerListSearch"
DoCmd.SetWarnings False

If Not IsNull(Me.txtOwner) Then
strWhere = strWhere & "([Owner] Like ""*" & Me.txtOwner & "*"") AND "
End If

If Not IsNull(Me.txtPropClass) Then
strWhere = strWhere & "([PropClass] Like """ & Me.txtPropClass & "*"") AND "
End If
Can anyone help me adjust these to get the right behavior? If needed I could post the whole code.
Thanks.
 

Users who are viewing this thread

Top Bottom