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

SORTING

Status
Not open for further replies.

296097

Programmer
Aug 13, 2004
32
US
A400 01 AMERICAN PLUMBING CO OF WINONA INC 450 44TH AVE
DIST 6 01 DISTRICT ENGINEER 2900 48TH ST N W
E0038 01 EATON CONSTRUCTION RR 1 BOX 60
1338 01 GARY LOVELACE - R.E. 2900 - 48TH STREET N.W.
H438 01 HOFFMAN CONSTRUCTION COMPANY 123 COUNTY HWY A
IN DIS 01 INTER PROG MAIL STOP 440 MAIL STOP 440
M630 01 MINNOWA CONSTRUCTION INC 850 WICKETT DR N W


I am just wondering if there is a way in CR 8.5 to sort my records first by A LETTER followed BY A NUMBER and a special records like DIS 6 AND IN DIS AND
At the end number will be Acesendingly.if someone has an idea how I can tackle this problem please let me know .I really want my records to be sorted like the one
I have at the bottom. Your help is really appreciated

A400 01 AMERICAN PLUMBING CO OF WINONA INC 450 44TH AVE
E0038 01 EATON CONSTRUCTION RR 1 BOX 60
H438 01 HOFFMAN CONSTRUCTION COMPANY 123 COUNTY HWY A
M630 01 MINNOWA CONSTRUCTION INC 850 WICKETT DR N W
DIST 6 01 DISTRICT ENGINEER 2900 48TH ST N W
IN DIS 01 INTER PROG MAIL STOP 440 MAIL STOP 440
1338 01 GARY LOVELACE - R.E. 2900 - 48TH STREET N.W.

 
For the string, use:

whileprintingrecords;
stringvar Str := {table.field};
Stringvar OutStr:= "";
Numbervar X;
For X := 1 to len(Str) do(
if not(isnumeric(mid(str,x,1))) then
// You'd use 2 different formuals and select Report->Sort
//Records to sort by these formulas:

// Formula for the string:
OutStr:=left(Str,x-1);
);
OutStr

//Formula for the number:
whileprintingrecords;
stringvar Str := {table.field};
Numbervar OutNum:=0;
Numbervar X;
For X := 1 to len(Str) do(
if not(isnumeric(mid(str,x,1))) then
// You'd use 2 different formuals and select Report->Sort
// Records to sort by these formulas:
//For the Number:
OutNum:=val(mid(Str,x));
);
OutNum

-k
 
Stewpud site, that was supposed to be from me:

// For the string
whileprintingrecords;
stringvar Str := "AS 123";
Stringvar OutStr:= "";
Numbervar OutNum:=0;
Numbervar X;
For X := 1 to len(Str) do(
if not(isnumeric(mid(str,x,1))) then
// You'd use 2 different formuals and select Report->Sort
// Records to sort by these formulas:
OutStr:=left(Str,x-1);
);
OutStr

//For the number
whileprintingrecords;
stringvar Str := "AS 123";
Stringvar OutStr:= "";
Numbervar OutNum:=0;
Numbervar X;
For X := 1 to len(Str) do(
if not(isnumeric(mid(str,x,1))) then
// You'd use 2 different formuals and select Report->Sort
// Records to sort by these formulas:
OutNum:=val(mid(Str,x));
);
OutNum

-k
 
You could use sort field formulas:

{@interimfield}
if left(tablename.fieldname),3 = 'DIS' or
left(tablename.fieldname),6 = 'IN DIS' or then 'XXXXX'
else
if NumericText(tablename.fieldname) = true then 'X' & tablename.fieldname
else tablename.fieldname

{@sortfield1}
left(@interimfield),1

{@sortfield2}
mid(@interimfield,2,4)

Then sort by {@sortfield1}, then by {sortfield2}, but display the {tablename.fieldname} in the detail line.
 
I am not sure if i understood your formula. i do not know why i should use two different formulas here. the field is string eventhough the value for the field varies like sometimes it is all number and other times it is mixed letters and number. thank you
 
296097

Please do not create multiple threads for the same problem. I just responded to your two other threads, and only then found this thread.

k-
As you might know, the site is in the process of renovation, and is not functioning up to par yet. The new site is intended to improve functionality. Unfortunately there is no general note to users to that effect. I think we just need to be patient for a while longer...

-LB
 
LB: I agree, however I'm accustomed to QA being done in QA, not production.

296097: Since you want the field sorted numerically, you need to have a numeric for the number portion for proper sortation, hence you need 2 types of fields.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top