Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / February 2008

Tip: Looking for answers? Try searching our database.

Partial match for query criteria

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
BJH712 - 14 Jan 2008 16:32 GMT
Hello,

I am trying to create a query that will deliver results based on matching
only a part of the text in a table field. For example, if I have a table that
contains the names, address and phone numbers of 10,000 businesses but I only
want my query to show me businesses that have the word "National" in their
name, how would I do that? I'm not sure how to set up the criteria.

Thanks for your help!
Ken Sheridan - 14 Jan 2008 16:55 GMT
Use the Like operator with wildcards.  In the 'criteria' row of the business
name column in query design view enter:

   Like "*National*"

Or you can use a parameter:

   Like "*" & [Enter all or part of business name:] & "*"

You'll then be prompted for the name when the query or any form or report
based on it is opened.

You might get some mismatches if the text you enter is a substring within a
word for instance, e.g. any names containing "international" would also be
included in the result set.  To find only distinct words or phrases enter  
the following in the 'field' row of a blank column in the query design grid :

  " " & "First international bank" & " "

and the following in the 'criteria' row

  Like "* " & [Enter all or part of business name:] & " *"

This will find occurrences of the string if preceded and followed by a
space, but if applied to the field itself would miss words or phrases at the
start or end of the field of course, which is why you have to apply it to a
computed column in which spaces are concatenated onto the start and end of
the value in the field.

Ken Sheridan
Stafford, England

> Hello,
>
[quoted text clipped - 5 lines]
>
> Thanks for your help!
BJH712 - 14 Jan 2008 18:21 GMT
Thank you! I knew it couldn't be that difficult. You've just saved me so much
time.

> Use the Like operator with wildcards.  In the 'criteria' row of the business
> name column in query design view enter:
[quoted text clipped - 37 lines]
> >
> > Thanks for your help!
Jeff Boyce - 14 Jan 2008 17:00 GMT
Create a new query in design view.

Add the [BusinessName] field.

In the selection criterion beneath it, put something like:

   Like * & [Enter partial business name] & *

When you run this query, it will prompt for a partial business name, then
search for any record with that string somewhere in the [BusinessName]
field.

Use your real field names.  Add any other fields in the query that you want
to see.

Regards

Jeff Boyce
Microsoft Office/Access MVP

> Hello,
>
[quoted text clipped - 7 lines]
>
> Thanks for your help!
BJH712 - 14 Jan 2008 18:21 GMT
Thank you! That was very helpful and it worked perfectly!

> Create a new query in design view.
>
[quoted text clipped - 27 lines]
> >
> > Thanks for your help!
Delboy - 04 Feb 2008 09:23 GMT
Thanks,  Just what i was looking for too! :)

Signature

Delboy

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.