Solved

Case-sensitive SQL Queries with Access Jet Engine

Posted on 1997-04-23
3
171 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 100 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

773 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