Solved

How do you force an uppercase search in a query?

Posted on 2007-11-13
7
1,037 Views
Last Modified: 2012-05-05
i cannot seem to filter my query with uppercase characters
...eg I cannot get it to filter values which contain "DR" and not "dr"

can anyone help?
0
Comment
Question by:mlnfis
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 4

Assisted Solution

by:MrXmas
MrXmas earned 150 total points
ID: 20277610
mlnfis,

Set your where clause to use the StrComp function.

So, if you want to find where MyFieldName = "DR" (and not "dr") then use this:

SELECT * FROM MyTableName WHERE StrComp(MyFieldName,"DR",vbBinaryCompare)=0

The StrComp function with the vbBinaryCompare will return a 0 only if the two strings are identical.

Hope that helps,

--Jim Christmas
0
 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 100 total points
ID: 20277656
I think in the query instead of vbBinaryCompare you will need to use 0  (zero) ... the literal value for vbBinaryCompare

mx
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 20277658
you can use the strComp in a query like this

select FieldName
from TableX
where StrComp([Fieldname],"DR",0)=0

vbBinaryCompare is not recognized in a query
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 4

Expert Comment

by:MrXmas
ID: 20277664
DatabaseMX and Capricorn1,

Good catch guys - Thanks.

--Jim Christmas
0
 

Author Comment

by:mlnfis
ID: 20285659
Hi Guys

Many Thanks for those answers..and, sorry, my SQL is pretty basic so slowly  I'm creeping my way to the answer!

With a table called [UIDC] and a fieldname [Company] the following:

SELECT UIDC.Company
FROM UIDC
WHERE StrComp([Company],"DR",0)=0;

Does indeed bring up any record with 'DR' as the whole field, but only where it is the whole field.

Can anyone help with if I need to bring up e.g. 'DR Jones' - ie where 'DR' can be followed by anything - I assumed it might work with the '*' (asterix) symbol - but can't seem to get this to work no matter how many or where I place them? ie

WHERE StrComp([Company],"DR*",0)=0;

Many Thanks
Mark
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 250 total points
ID: 20285906
try this

SELECT UIDC.Company
FROM UIDC
WHERE StrComp(Mid(Trim([Company]),1,2),"DR",0)=0;
0
 

Author Closing Comment

by:mlnfis
ID: 31409143
Hi people

Many many thanks to all of you - that last solution worked great - has made my day at work much easier!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
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 …

713 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