Access Query - How to query text fields looking for specific lower and upper case text strings.

Posted on 2011-10-13
Last Modified: 2012-08-14
How can I create a query that generates text strings with exact lower/upper case?

I would like a query which generates all products that start with lower case "a"
I would like a query which generates all products that start with upper case "A"
Question by:brothertruffle880
    LVL 58

    Expert Comment

    select * from products where Asc(Left(code,1)) = Asc("a")
    select * from products where Asc(Left(code,1)) = Asc("A")
    LVL 58

    Accepted Solution

    ASC looks at the first character only, so these are equivalent:

    select products.* from products where Asc(code) = Asc("a")
    select products.* from products where Asc(code) = Asc("A")
    LVL 47

    Expert Comment

    by:Dale Fye (Access MVP)
    Use the string comparison function strComp().

    Check out Access help for the syntax and the retrun values.  you will want to use vbBinaryCompare as the 3rd parameter.

    Author Comment

    Where do I type these things in the query design view?
    LVL 47

    Assisted Solution

    by:Dale Fye (Access MVP)

    To test the the first character of [SomeField] = "A", add a new column to the query grid, like:

    Expr1:strComp(left([SomeField], 1), "A", 0)
    Criteria: 0


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
    In the article entitled Working with Objects – Part 1 (, you learned the basics of working with objects, properties, methods, and events. In Work…
    In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
    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…

    760 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

    7 Experts available now in Live!

    Get 1:1 Help Now