?
Solved

Case-sensitive SQL Queries with Access Jet Engine

Posted on 1997-04-23
3
Medium Priority
?
200 Views
Last Modified: 2012-08-14
How do I get the VB4 Access Jet Engine to do case-sensitive queries? Eg.

SELECT * FROM someTable WHERE someField = 'i'

Here "someField" is assumed to be a text field, and I would like only 'i' records (and not 'I' records) to be returned. The default behaviour seems to be case-insensitive.
0
Comment
Question by:seumas
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
milton042297 earned 200 total points
ID: 1425662
Your problem will be solve now ...

Use the "Like" operator instead "=".
This example returns a list of employees whose names begin with the letters A through D.
 
SELECT * FROM Employees WHERE LastName Like "[A-D]*"

 
The following table shows how you can use Like to test expressions for different patterns.
 
Kind of match              Pattern       Match (returns True)      

Multiple characters      "a*a"              "aa", "aBa", "aBBBa"      
                      "*ab*"              "abc", "AABB", "Xab"      

Special character      "a[*]a"              "a*a"      
Multiple characters      "ab*"              "abcdefg", "abc"      
Single character      "a?a"              "aaa", "a3a", "aBa"      
Single digit              "a#a"              "a0a", "a1a", "a2a"      
Range of characters      "[a-z]"              "f", "p", "j"      
Outside a range              "[!a-z]"      "9", "&", "%"      
Not a digit              "[!0-9]"      "A", "a", "&", "~"      
Combined              "a[!b-m]#"      "An9", "az0", "a99"      


Good Luck...
0
 
LVL 1

Expert Comment

by:milton042297
ID: 1425663
Sorry seumas but the table is not well, but you can get this table, on VB help.
0
 

Author Comment

by:seumas
ID: 1425664
Hi,

I tried out this solution and it didn't work. The "Like" operator works fine in plain VB code, but in an SQL statement it is still case-insensitive. I got a solution from the newsgroup however:

SELECT * FROM someTable
WHERE someField = 'i'
AND StrComp([someField],'i',0) = 0 ;

Seumas
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month16 days, 6 hours left to enroll

850 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