primary key

when you define a primary key of some fields on a table, the system sorts the data according to this fields. Is there some way to define a primary key made of a code-field (cf) and two decimal-fields (df1,df2) and to tell the system to sort the tabledata in ascending order for cf and df2, in descending order for df2?? (1. ASC for cf, 2. DESC for df1, 3. ASC for df2) Edited by - mlml772 on 2002 Feb 28 16:58:54

No, you would have to store the values of the df2 field with value * -1, and then when showing records have the sourceexpression do the same - to show the actual value. On the table you would add code on the OnValidate trigger to handle this, and on the form on the SourceExpression of the Textbox. This way you will have the desired sorting. /Soren Edited by - SNielsen on 2002 Feb 28 18:37:09

ingenious idea, thank you

Displaying a different field value on a form than the value in the database (e.g. multiplying the field value by -1) can be very confusing for users when the apply filters. Records that would, judging by the value on the screen, be expected not to “fit” within the filter criteria would show up nonetheless, since their underlying value in the database matches the filter. I would choose to have two fields: one (non-editable) field that is merely used for sorting, and an other that is displayed, and can be edited by the user. Modifying the editable field would trigger code that updates the non-editable field. If the non-editable field is part of the primary key, use RENAME to update the field value. Kind regards, Jan Hoek Weha Automatisering BV Woerden - The Netherlands Edited by - jhoek on 2002 Mar 01 08:56:58

Jan wrote:

quote:


can be very confusing for users when the apply filters


Agree with you - implementation is pretty much the same, but as you pointed out it would be more user-friendly with two fields for this - and then let the user key information into the non-key field - do the validation behind the scenes and voila. /Soren

Thank you both very much, but if I’ll ever have the same problem with non-decimal or integer field isnt there really no easy way to resolve it? (like in oracle where you can specify desc/asc in selects)