Solved

"Contains" function in MS-Access 2007

Posted on 2013-11-19
3
2,942 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Lync meeting or Lync conferencing is what many organizations would like to deploy to allow them save money. But companies are now giving up for various reasons, one of which is that they cannot join external meetings (non-federated company meetings)…
The System Center Operations Manager 2012, known as SCOM, is a part of the Microsoft system center product that provides the user with infrastructure monitoring and application performance monitoring. SCOM monitors:   Windows or UNIX/LinuxNetwo…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

839 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