Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Case Sensitive If Statment?

Case Sensitive If Statment?

Case Sensitive If Statment?


Hello Group,

Crystal 8, strait-up database

Trying to get the If statment to detect a difference in case.  See the formula field below for code.

-------- Originator Formula Field ----------
Local stringVar LocalTemp := Right((Trim({CLIENT.ClientType2})),1);

if  LocalTemp = "A" then  LocalTemp := "DRH";
if  LocalTemp = "a" then  LocalTemp := "TCG";

Is there a way for the answer to be DRH and not TCG?


RE: Case Sensitive If Statment?

I had always thought that crystal made it's comparisons case-sensitive but as you point out this is not the case...which makes you wonder what the heck is the usefulness of the Uppercase and Lowercase functons

my solution to this is to wrap both sides of the comparison with the function ASC() which will force it to campare the ascII values

so try this

if asc(Localtemp) = asc("A") then LocalTemp := "DRH";
if asc(Localtemp) = asc("a") then LocalTemp := "TCG";

that should work...


RE: Case Sensitive If Statment?

Apparently the setting in Report - Options that says "Case Insensitive SQL data" also affects the case sensitivity of formulas.  That surprises me, because I don't think that was always the case.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB

RE: Case Sensitive If Statment?

I think this lack of case sensitivity sort of crept in at some point....I recall in CR5 anyway always having to bulletproof my parameter inputs by forcing them to uppercase for testing...it appears I don't have to do that anymore....


RE: Case Sensitive If Statment?

Thanks for your responses!

I tried the solution from Ngolem but didn’t work for every condition.  It somehow still had problems comparing the ASCII numbers.  But I was determined this is the way out, so I changed the if statements up a little bit and now it works great!  See below:

-------------- Originator Formula Field ----------------

Local NumberVar NumTemp := Asc(Right((Trim({CLIENT.ClientType2})),1));
Local StringVar StrTemp := "";

if NumTemp = 65  then StrTemp := "DRH";  //UpperCase A
if NumTemp = 97  then StrTemp := "TCG";  //LowerCase a



I am not sure why Ngolem’s suggestion did not work, in theory it was rock solid, but in practice something was not right.  Still wondering about that one...  Maybe Seagate will have an option for case comparison in later versions.

Thanks everyone!

RE: Case Sensitive If Statment?

I think it is with multiple characters in a string it only performs the ASC() on the first character

Thanks for correcting it


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close