Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lower-case or invalid characters in a customer database

Status
Not open for further replies.

Madawc

Programmer
Sep 5, 2002
7,628
GB
Where I work, the system runs on a mainframe with various PC ‘front-ends’. Crystal is used for head-office analysis of the data, with the Crystal database reflecting the position as it was yesterday.

Customer and account details are supposed to be typed in as UPPER CASE, with just the standard ‘special characters’. I was asked to write a program that would spot invalid characters among the hundreds of thousands of customer details. I did this using the following Boolean, which I then tested for in Record Selection:
Code:
Instr({Customer.Surname}, "`") > 0 or
Instr({Customer.Surname}, "|") > 0 or
Instr({Customer.Surname}, "\") > 0
The details could then be manually corrected using the mainframe system (which is highly secure). This was fine, and I was asked to extend it to cases where lower-case names had been used.

I could have repeated the same test for each lower-case letter, but that seemed long winded. I decided that UpperCase("Mr Smith") would return "MR SMITH", a difference which could be spotted even in record selection. Specifically, I tried:
Code:
{Customer.Surname} <> UpperCase({Customer.Surname})
Bafflingly, this found nothing. Luckily a colleague spotted the problem: Crystal was cleverly ignoring the difference in case, which would be just what you’d want in most cases. In this instance, the answer was:
Code:
StrCmp ({Customer.Surname}, UpperCase({Customer.Surname}), 0) <> 0
This is apparently just like a Visual Basic and will be obvious if you already know that language, but not to me. The final ‘0’ specifies that the comparison is to be case-sensitive, with ‘1’ indicating case-insensitive. ‘0’ is the default, at least for Crystal 10, but defaults sometimes change. I prefer my code to be as explicit as it reasonably can be.

I could find nothing similar from a Search for ‘lower case’, so I thought the solution would be worth posting.


[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top