Solved

How do you force an uppercase search in a query?

Posted on 2007-11-13
7
1,040 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

626 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