>I have a form with a relation set id_num to id_num
>I have 2 grids one with the main data and the other with the child data.
>The child table has 2 index id_num and date
>
>How do I sort the child grid by date in descending order.
>
>it seems that as long as the relation is set I cannot use date as the sort order.
Usually it's easier not to use Set Relation at all but rather create a Parameterized Local View like
Create View vTest As Select id_num, datefield From theTable Where id_num = ?yourParameter Order By datefield
That View would get stored in yourDatabase.DBC persistently so that you can now USE it almost like a table.
For instance, add it to your form.DataEnvironment, set .NoDataOnLoad=.T., and in form.Init() and whenever the parent table's record pointer moves, call a custom method looking like:
Local yourParameter
yourParameter = parentAlias.id_num
Requery("vTest")
If you prefer to continue using Set Relation, you can use an concatenated index expression as long as Set Exact is OFF, assumed your id_num is numeric and the datefield is type "D", it might look like "Index On BinToC(id_num)+DToS(datefield).
hth
-Stefan