Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 03-16-2019, 05:16 PM   #1
Ksabai
Newly Registered User
 
Join Date: Jul 2017
Posts: 53
Thanks: 3
Thanked 0 Times in 0 Posts
Ksabai is on a distinguished road
Search Using only part of the Text

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.

Ksabai is offline   Reply With Quote
Old 03-16-2019, 05:39 PM   #2
June7
Newly Registered User
 
June7's Avatar
 
Join Date: Mar 2014
Posts: 1,395
Thanks: 0
Thanked 340 Times in 339 Posts
June7 will become famous soon enough
Re: Search Using only part of the Text

What other criteria is used to build filterStr? What you have using LIKE and * should work.
__________________
To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression. Attachment Manager is below Advanced editor window, click Go Advanced below Quick Reply window.
DEBUG! DEBUG! DEBUG!
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
June7 is offline   Reply With Quote
Old 03-16-2019, 05:44 PM   #3
Ksabai
Newly Registered User
 
Join Date: Jul 2017
Posts: 53
Thanks: 3
Thanked 0 Times in 0 Posts
Ksabai is on a distinguished road
Re: Search Using only part of the Text

i dont exactly know what to write, can u write me the code.

Ksabai is offline   Reply With Quote
Old 03-16-2019, 05:50 PM   #4
Cronk
Newly Registered User
 
Join Date: Jul 2013
Posts: 2,032
Thanks: 3
Thanked 441 Times in 434 Posts
Cronk will become famous soon enough Cronk will become famous soon enough
Re: Search Using only part of the Text

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?
Cronk is offline   Reply With Quote
Old 03-16-2019, 05:59 PM   #5
Ksabai
Newly Registered User
 
Join Date: Jul 2017
Posts: 53
Thanks: 3
Thanked 0 Times in 0 Posts
Ksabai is on a distinguished road
Re: Search Using only part of the Text

yes it runs but returns only the first record in the database
Ksabai is offline   Reply With Quote
Old 03-16-2019, 06:07 PM   #6
June7
Newly Registered User
 
June7's Avatar
 
Join Date: Mar 2014
Posts: 1,395
Thanks: 0
Thanked 340 Times in 339 Posts
June7 will become famous soon enough
Re: Search Using only part of the Text

Code in what event?

If you want to provide db for analysis, follow instructions at bottom of my post.
__________________
To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression. Attachment Manager is below Advanced editor window, click Go Advanced below Quick Reply window.
DEBUG! DEBUG! DEBUG!
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
June7 is offline   Reply With Quote
Old 03-17-2019, 06:13 PM   #7
essaytee
Need a good one-liner.
 
essaytee's Avatar
 
Join Date: Oct 2008
Location: Melbourne, Australia
Posts: 410
Thanks: 8
Thanked 83 Times in 80 Posts
essaytee is on a distinguished road
Re: Search Using only part of the Text

Quote:
Originally Posted by Ksabai View Post
yes it runs but returns only the first record in the database

The record that is returned, does that meet the filter requirement?

__________________
Steve.

I know UNIX, PASCAL, C, FORTRAN, COBOL, and nineteen other high-tech words.
essaytee is offline   Reply With Quote
Old 03-17-2019, 06:57 PM   #8
Ksabai
Newly Registered User
 
Join Date: Jul 2017
Posts: 53
Thanks: 3
Thanked 0 Times in 0 Posts
Ksabai is on a distinguished road
Re: Search Using only part of the Text

The Issue is Solved, thanks for the help.
Ksabai is offline   Reply With Quote
Old 03-17-2019, 07:33 PM   #9
essaytee
Need a good one-liner.
 
essaytee's Avatar
 
Join Date: Oct 2008
Location: Melbourne, Australia
Posts: 410
Thanks: 8
Thanked 83 Times in 80 Posts
essaytee is on a distinguished road
Re: Search Using only part of the Text

Quote:
Originally Posted by Ksabai View Post
The Issue is Solved, thanks for the help.
How was it resolved?

__________________
Steve.

I know UNIX, PASCAL, C, FORTRAN, COBOL, and nineteen other high-tech words.
essaytee is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Search for part of a file name XLEAccessGuru Modules & VBA 3 08-05-2008 04:36 AM
Search part of name field CSCS Queries 4 06-02-2008 12:58 PM
Search on part of a number blueanchor General 2 01-19-2006 11:21 PM
returning part of text search result Tech Queries 1 06-20-2003 05:04 PM
search part of field with query takis_x Queries 1 07-09-2002 01:34 AM




All times are GMT -8. The time now is 12:36 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World