Page 1 of 1

Sorting TMSQuery

Posted: Thu 14 Feb 2008 11:44
by FaNIX
Hi,

How do one sort with the TMSQuery object, because TADOQuery has a Sort property, but I see that the TMSQuery does now. Please explain...

Thanks.

Posted: Thu 14 Feb 2008 12:14
by FaNIX
Read on the forum, and got it working:

Code: Select all

procedure Sort_Grid(ACol : Integer; var ASortBy : String; var ADataset : TMSQuery);
var
  fldName : String;
begin

  if ASortBy = 'ASC' then
    ASortBy := 'DESC'
  else
    ASortBy := 'ASC';

  fldName := ADataset.FieldList.fields[ACol].FieldName;

  ADataset.IndexFieldNames := fldName +' '+ ASortBy +';';

end;