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 (Parameter is a DB field)

Status
Not open for further replies.

Senseial

Programmer
Feb 11, 2004
40
CA
Hello all

Is there any way that I can have parameter field = database field but the trick here the database field is passed by a parameter. The reason for this is that they can sort by primary field and secondary field asc and desc. I have all my formulas right I just don't know how to make this work eg:
IF {?Primary Sort Descending } = 'TRUE'
THEN {?Primary Sort Field} this is my problem how can I have {?Primary Sort Field} equal to a database field that they want to sort by and this can be any field that is availabe to them on the report so that they can sot ASC or DESC.

All the parameters are coming from from .NET application
uing CR10 on XP prof. machine

Thanks
Alex
 
One approach is to set up four discrete string parameters:
{?primary sort} with options "asc" and "desc"
{?secondary sort} with options "asc" and "desc"
{?primary field} with options like "Amt","Cust ID","Shipper"
{?secondary field} with the same options as {?primary field}

Then create six formulas:

//{@primary field}:
if {?primary field} = "Amt" then totext({table.amount},"00000") else
if {?primary field} = "Cust ID" then totext({table.customerID},"000") else
if {?primary field} = "Shipper" then {table.shipper}

//{@secondary field}:
if {?secondary field} = "Amt" then totext({table.amount},"00000") else
if {?secondary field} = "Cust ID" then totext({table.customerID},"000") else
if {?secondary field} = "Shipper" then {table.shipper}

//{@prim sort asc}:
if {?primary sort} = "asc" then {@primary field}

//{@prim sort desc}:
if {?primary sort} = "desc" then {@primary field}

//{@secondary sort asc}:
if {?secondary sort} = "asc" then {@secondary field}

//{@secondary sort desc}:
if {?secondary sort} = "desc" then {@secondary field}

Go to report->sort fields and enter:
{@prim sort asc} (check "asc")
{@prim sort desc} (check "desc")
{@secondary sort asc} (check "asc")
{@secondary sort desc} (check "desc")

Then add {@primary field} and {@secondary field} to the report canvas as your report fields.

-LB
 
Thank you that works great. The only problem I have with this is that sometimes I have more than 10 fields and I have to maintain. IS there any way I can pass a prameter that is ORDER BY and attach it to a my view which is my source.

Thanks
 
Someone else will have to answer that question.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top