Solved

"Contains" function in MS-Access 2007

Posted on 2013-11-19
3
2,421 Views
Last Modified: 2013-11-19
I am writing a query and I want to find all the records with a field "Name" that contains more than one string; i.e. Name Contains ("XYZ","ABC")

What is the syntax for the Criteria for the field?

Thanks

Glen
0
Comment
Question by:GPSPOW
  • 2
3 Comments
 
LVL 26

Accepted Solution

by:
Shaun Kline earned 500 total points
ID: 39660455
If you are looking for an exact match, you can use the IN keyword:

Name IN ("XYZ", "ABC")

If you are looking for a partial match, you can use the LIKE keyword:

Name LIKE "XYZ*" OR Name LIKE "ABC*"

The star represents a pattern search, so the above would be where name starts with. For an ends with search, put the star at the beginning. For an "in the middle" search, put stars at both ends.

Here is a URL that may help:
http://office.microsoft.com/en-us/access-help/examples-of-query-criteria-HA010066611.aspx
0
 
LVL 26

Expert Comment

by:Shaun Kline
ID: 39660459
If you want to find all Name values that contain both values, then you would need to do:
Name LIKE "*XYZ*" AND Name LIKE "*ABC*"
0
 

Author Closing Comment

by:GPSPOW
ID: 39660468
Thanks

Glen
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now