Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How do you force an uppercase search in a query?

Posted on 2007-11-13
7
Medium Priority
?
1,042 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 600 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 400 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
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 1000 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

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.

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.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
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…

704 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