[SOLVED]DBGrid Title Click to sort-Quick question lazarus / 16-Databases ---------------------------------------------------------------------- What I can do · 2024-05-25 18:12 OS: Microsoft Windows 10 Home Version 10.0.18363 Compiler: Lazarus 3.2 FPC:3.2.2 DataBase *.mdb Project:  DBGrid title click sort Why does this ... Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.DBGrid1TitleClick(Column: TColumn);begin SQLCheckQurey.IndexFieldNames := Column.FieldName + ' DESC';end;  Work perfectly but this Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.DBGrid1TitleClick(Column: TColumn);begin SQLCheckQurey.IndexFieldNames := Column.FieldName + ' ASC';end;  produce an error ' ---------------------------------------------------------------------- What I can do · 2024-05-26 23:09 LOL, that's simple. the 'DESC' is the option but 'ASC' is the default and doesn't need to be redefined. Sort of like calling a SQL command 'SORT BY aField ASC ASC' FYI Here is a simple option for a quick sort toggle  on title click Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.DBGrid1TitleClick(Column: TColumn);begin if POS('DESC',SQLCheckQurey.IndexFieldNames)=0 then   SQLCheckQurey.IndexFieldNames := Column.FieldName + ' DESC' else   SQLCheckQurey.IndexFieldNames := Column.FieldName; SQLCheckQurey.First;end;  Hope this helps anyone, I read a lot of really cool stuff about Grid sort and I found it worth the read