Search Using only part of the Text (1 Viewer)

Ksabai

Registered User.
Local time
Yesterday, 23:10
Joined
Jul 31, 2017
Messages
104
I have the following Code:

Dim filterStr As String
filterStr = ""

If Len(txtBuyerName) > 0 Then
If filterStr = "" Then
filterStr = filterStr & " ([BuyerName] Like '*" & txtBuyerName & "*')"
Else
filterStr = filterStr & " And ([BuyerName] Like '*" & txtBuyerName & "*')"
End If
End If

Me.Form.Filter = filterStr
If filterStr <> "" Then
Me.Form.FilterOn = True
Else
Me.Form.FilterOn = False
End If

With the above code i need to type full name of the customer to get the result. But i would like to get is like if the Name of the Buyer is "Microsoft Corporation USA". Even if i type "Micro" or "rosft" i should be able to get all the buyer names with "Micro" in any part of the Name. Kindly Help.
 

June7

AWF VIP
Local time
Yesterday, 22:10
Joined
Mar 9, 2014
Messages
5,424
What other criteria is used to build filterStr? What you have using LIKE and * should work.
 

Ksabai

Registered User.
Local time
Yesterday, 23:10
Joined
Jul 31, 2017
Messages
104
i dont exactly know what to write, can u write me the code.
 

Cronk

Registered User.
Local time
Today, 17:10
Joined
Jul 4, 2013
Messages
2,770
There's nothing wrong with the code apart from several superfluous lines and an error bomb waiting if txtBuyerName is null.


What event contains the code? Have you checked if it runs?
 

Ksabai

Registered User.
Local time
Yesterday, 23:10
Joined
Jul 31, 2017
Messages
104
yes it runs but returns only the first record in the database
 

June7

AWF VIP
Local time
Yesterday, 22:10
Joined
Mar 9, 2014
Messages
5,424
Code in what event?

If you want to provide db for analysis, follow instructions at bottom of my post.
 

Ksabai

Registered User.
Local time
Yesterday, 23:10
Joined
Jul 31, 2017
Messages
104
The Issue is Solved, thanks for the help.
 

Users who are viewing this thread

Top Bottom