Solved

How do you force an uppercase search in a query?

Posted on 2007-11-13
7
1,033 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
Comment Utility
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 - Access MVP)
DatabaseMX (Joe Anderson - Access MVP) earned 100 total points
Comment Utility
I think in the query instead of vbBinaryCompare you will need to use 0  (zero) ... the literal value for vbBinaryCompare

mx
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 4

Expert Comment

by:MrXmas
Comment Utility
DatabaseMX and Capricorn1,

Good catch guys - Thanks.

--Jim Christmas
0
 

Author Comment

by:mlnfis
Comment Utility
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 119

Accepted Solution

by:
Rey Obrero earned 250 total points
Comment Utility
try this

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

Author Closing Comment

by:mlnfis
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
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 …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now