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

Sort Multiple Fields from ASP - Urgent Please help

Status
Not open for further replies.

amutinu

Programmer
Oct 19, 2001
50
US
Hi
I am using Crystal reports 8.5 and Sql Server to retrieve my reports on the web (ASP). I have a field that i passing in to sort on that field but i need to figure out how to sort on multiple fields (like FirstName and LastName). Please let me know if anybody has an idea. I need to turn this report in this afternoon so your quick help will be greatly apprecaited.

thanks,

Kiran
 
I just had this problem 1 week ago and I found this in the help for CR 6.0 (I duplicated this 3 times and set the sort order for all three variables):


How to set sort order using parameter fields

To set the sort order using parameter fields, you need to create a formula that includes a parameter field and then sort on that formula. For example, assume that you have a customer list report based on the Customer table. For each customer, you show the Customer Name, City, Region, Country, and Phone Number. You want to be able to sort the report by Country, by Region, or by City, depending on your needs at the time.

1 Create a parameter field and name it SortField. See How to create a parameter field.

2 In the Prompting Text edit box, type a prompt similar to this:

Type R to sort by Region or C to sort by City, otherwise data will be sorted by Country.

3 Create a formula similar to this and call it Sort:

If {?SortField} = "C" Then
{customer.CITY}
Else
If {?SortField} = "R" Then
{customer.REGION}
Else
{customer.COUNTRY}

«This formula prompts for a value for the parameter field {?SortField}. If you enter "C", the formula will sort by the City field. If you enter "R" it will sort by the Region field. If you enter anything else, or do not enter anything at all, the formula will sort by the Country field. See How to create multi-condition If-Then-Else formulas.»

4 Place the formula in the Report Header section of your report and toggle its Suppress option on in the Section Expert so it does not print.

5 Click the Sort Records button on the standard toolbar, choose your formula, @Sort, as your sort field. See How to do a single field sort.

Now when you run the report, the program will prompt you for a sort field, the formula will return a value based on your selection, and the sort facility will use that value as your sort field.

Parameter Fields Index
Parameter Field Objects Overview
How to do a multiple field sort
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top