Print Page | Close Window

Code help

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Writing Code
Forum Discription: .NET programming API, report integration
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=22143
Printed Date: 29 Mar 2024 at 2:57am


Topic: Code help
Posted By: rockMEhardplace
Subject: Code help
Date Posted: 15 Nov 2016 at 11:54am
Hoping you guys/gals can help me. I'm trying to sort some information in order, but my information is a bit complicated.

Here is an example of some numbers I want to sort:

15-203 0-1
15-20012 0-5
14-9880 2-14

-The number before the dash represents a year (2015, 2014)
-The after the dash but before the space represents what number case we're on that year (203rd case, etc)
-And the numbers after the space refers to specific items (for which I still need sorted, but have no bearing on the case #)

My issue is, the numbers above are string fields and although I've converted them tonumber fields, they are not sorting correctly.

For instance: 15-203 refers to the 203rd case of the 2015 year, and 15-20012 represents the 20,012th case we had in 2015. They belong nowhere near each other, but because they both start with 20, they are being sorted that way. I need it to sort according to ones, tens, hundreds, thousands place.

Here's what I had so far:

if len({case})<1 then ({case})

else

mid({case}, 1)&

If isnumeric (mid({case}, 4) ) then
              
tonumber (mid({case}, 4)) &

Replace(Replace(CStr({case}), ',', ''), '.00', '')

I was told to use the formula below to do what I need to do, but it's not working:

if instr( {Customer.Customer Name}," ") > 0 then
mid ( {evlocal.localid} , 1, instr( {evlocal.localid}," ") - 1 )

Any help would be so appreciated! Thank you!





Print Page | Close Window