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

Changing sort in a formula? 1

Status
Not open for further replies.

johnism

Technical User
Jul 31, 2002
53
US
How can I change the sort in a formula?
For example
if{?Sort}="A" then {Rrload.TrackNo}
this will sort {Rrload.TrackNo} in Ascending order
how can I ( with code ) change that?
is it somthing like
{{Rrload.TrackNo},'D'} to change it to descending?
Thnaks ,
John
 
Are you doing this within an application, or just a report with a parameter? Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
 
with in an application, where our custom software sets the parameter through the vcl.
 
I need to know what I need to add to this

if{?Sort}="A" then {Rrload.TrackNo}
else if{?Sort}="B" then {Rrload.TrackNo}

so that if {?Sort}is "A" than {Rrload.TrackNo} will be ascending,and if {?Sort} is "B" than {Rrload.TrackNo} will be descending.
 
You can change the sort FIELD from a paramter, but you can't change the sort DIRECTION from a parameter field.

You can change the Sort direction by passing a different command to CR, but you would have to be able to add code to the app.

There is a workaround if this field is number or date. Let me know what the data type is. Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
 
write a new formula field called @SortField with the following formula:

if{?Sort}="A" then {Rrload.TrackNo}
else 0 - {Rrload.TrackNo}

Now go to "report-sort records" and change your sort field from TrackNo to this formula field. When you pick B the column will be full of negative numbers and will sort in the opposite direction. Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top