ACC: How to Return Case-Sensitive Matches in Queries

Last reviewed: April 2, 1997
Article ID: Q95605
The information in this article applies to:
  • Microsoft Access versions 1.0, 1.1, 2.0, 7.0, 97

SUMMARY

Advanced: Requires expert coding, interoperability, and multiuser skills.

You can use the Asc() function to have Microsoft Access differentiate between case sensitive text strings. When you use this function in a select query, Microsoft Access can locate an exact case sensitive match.

MORE INFORMATION

This technique is useful in a situation where you need to find all the records in a field that contain lowercase text rather than uppercase text for the first character. An example of this might be in the Employees table of the Northwind.mdb (or NWIND.MDB in versions 1.x and 2.0) sample database.

NOTE: You can perform full case-sensitive comparisons in a query using the built-in StrComp() function. All you need to do is create a column with the following expression

   StrComp([FieldName],"SearchForThis",0).

and then set the criteria of this column to 0.

Please note that the following example will find only the first character.

Suppose the text field called FirstName contains values such as the following records:

   FirstName
   ---------
   andrew
   Andrew
   Nancy

   NOTE: In versions 1.x and 2.0, there is a space in the First Name field.

If you need to find all the records that contain the lower case "andrew" instead of "Andrew," use the Asc() function. To do this, create the following select query:

   Query: QueryTest
   --------------------------------
   Field name: FirstName
      Show: True
   Field name: Asc([Firstname])
      Show: True
      First Criteria Line:  Asc("a")

Note that when you run this query, the query returns only the record for "andrew," not for "Andrew."

REFERENCES

For more information about the Asc() function, search the Help Index for "Asc function."

For more information about Case-Sensitive comparisons, search the Help Index for "case sensitivity."


Additional query words: chr chr$ how to
Keywords : kbusage QryParm
Version : 1.0 1.1 2.0 7.0 97
Platform : WINDOWS
Hardware : X86
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 2, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.