Selecting sort field at runtime

Meeting place for R&R customers and clients to share tips and ideas. Post your questions, messages or problems here.
Post Reply
moonraker12
Posts: 2
Joined: Tue Oct 10, 2017 12:44 pm

Selecting sort field at runtime

Post by moonraker12 » Thu Sep 03, 2009 7:04 pm

Is there any way to select the field to sort by at runtime? I tried a RRparameter and referenced it in the sort screen but it totally ignores what I enter at runtime and does not sort. Additionally, is there any way to select ascending or desending at runtime as well? I^me using version 12.x

kfleming
Posts: 5795
Joined: Tue Oct 10, 2017 12:44 pm

=> RE: Selecting sort field at runtime

Post by kfleming » Tue Sep 08, 2009 10:09 am

You can use RI_SORT fields in your control table to set sort order. The RI_SORT fields let you choose the sort order as well as the sort field.____My guess is that you are using the parameter field directly for your sort (which returns a literal value) and that is way it appears to ignore your entry. Typically you would create a calculated field that evaluates the parameter entry and returns a field based on the parameter entry.__For example you could have the user select either FIRST or LAST as the parameter value.__Then you would sort using a calculated field with the expression:__IIF(PARAM="FIRST",FNAME,LNAME)______Kathleen__R&R Support

Thomas_Freitas_(Guest)
Posts: 123
Joined: Tue Oct 10, 2017 12:44 pm

=> RE: Selecting sort field at runtime

Post by Thomas_Freitas_(Guest) » Mon Sep 21, 2009 1:08 pm

I use a database connection where I link using the record number function. When the user runs the report, I create a unique databases for the user and in the control database, RRWRUNIN.DBF, in my case, I use the alias for the report to use that unique database. In the database is a field I have called SORT. I put a number in there so that I can use it on any database. I then have a variable in my R&R that looks something like this.____Case(number=1,"car_number",2,"Car_initial",3,"default_sort")____I also have a header case selection so that the sort is named in the report for the user.______Tom Freitas

kfleming
Posts: 5795
Joined: Tue Oct 10, 2017 12:44 pm

==> RE: Selecting sort field at runtime

Post by kfleming » Tue Sep 22, 2009 3:42 pm

Your case statement is returning literal text rather than an actual field name. That is why it is not working.__You need to have 3 different character fields in your case statement.__For example:__Case(number=1,car_number,2,Car_initial,3,default_sort) ____will work as long as you have 3 fields named __car_number__Car_initial__default_sort____that all have the same datatype.____Kathleen__R&R Support____

Post Reply