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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Alpha Range By Last Name

Status
Not open for further replies.

austin22

Technical User
Aug 6, 2007
66
US
Hello all,
I am using Crystal Report XI. I need a simple formula that will allow me to do a range on a list of last names.
For example, I would like to see all last names that starts with range of A-L...this is what I have now:

{DefLastName} startswith ["A","B","C","D","E","F","G","H","I","J","K","L"]

However, I thought there should be a better way to do this.

Please advise.
 
If asc({DefLastName}[1]) in 65 to 76 then 'Range A-L' else
If asc({DefLastName}[1]) in 77 to 90 then 'Range A-L' else
'Unknown Character'


'J

CR8.5 / CRXI - Discovering the impossible
 
Oops - Should have obviously read:

If asc({DefLastName}[1]) in 65 to 76 then 'Range A-L' else
If asc({DefLastName}[1]) in 77 to 90 then 'Range M-Z' else
'Unknown Character'

CR8.5 / CRXI - Discovering the impossible
 
You could also use:

if {DefLastName}[1] in "A" to "L" then
"A to L" else
if {DefLastName}[1] in "M" to "Z" then
"M to Z" else
"Unknown"

...but CR8user's solution will work, too.

-LB
 
Thank you so much to both CR85user and lbass for the solution.

Yes, both work just great!

Again, thanks!

austin22
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top