• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5568
  • Last Modified:

"Contains" function in MS-Access 2007

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
GPSPOW
Asked:
GPSPOW
  • 2
1 Solution
 
Shaun KlineLead Software EngineerCommented:
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
 
Shaun KlineLead Software EngineerCommented:
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
 
GPSPOWAuthor Commented:
Thanks

Glen
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now