Baldur3635
Technical User
I have a MyDataModule. In it I have MyConnection1, a query and this is a second Query.
I have a MyDataSource2 and a MyQuery2. On the form I'm busy with, there is a ListBox, populated with the fields that I want to sort on. The idea is, the user selects a field and then the code (below) displays the sorted List in a dbGrid. It works fine, with ine teeny exception, It doesn't sort on anything other than the itemno (which is the Primary Key.
I have the following code
Procedure DoSort;
var
QString : String;
begin
dmFiles.MyQuery2.Active := True;
dmFiles.MyQuery2.Close;{close the query}
QString := '';
//assign new SQL expression
dmFiles.MyQuery2.SQL.Clear;
dmFiles.MyQuery2.SQL.Add ('Select itemno, name, code1, code2,' +
'vendor, type, rating, tested ');
dmFiles.MyQuery2.SQL.Add('from files4 ');
dmFilms.MyQuery2.SQL.Add ('order by ');
QString := SortForm.SortSelect.Items [SortForm.SortSelect.ItemIndex];
dmFilms.MyQuery2.SQL.Add (QString);
dmFilms.MyQuery2.Open; {open query + display data}
End;
I just know I should see the answer, but I can't. I'm sure someone else can!
I have a MyDataSource2 and a MyQuery2. On the form I'm busy with, there is a ListBox, populated with the fields that I want to sort on. The idea is, the user selects a field and then the code (below) displays the sorted List in a dbGrid. It works fine, with ine teeny exception, It doesn't sort on anything other than the itemno (which is the Primary Key.
I have the following code
Procedure DoSort;
var
QString : String;
begin
dmFiles.MyQuery2.Active := True;
dmFiles.MyQuery2.Close;{close the query}
QString := '';
//assign new SQL expression
dmFiles.MyQuery2.SQL.Clear;
dmFiles.MyQuery2.SQL.Add ('Select itemno, name, code1, code2,' +
'vendor, type, rating, tested ');
dmFiles.MyQuery2.SQL.Add('from files4 ');
dmFilms.MyQuery2.SQL.Add ('order by ');
QString := SortForm.SortSelect.Items [SortForm.SortSelect.ItemIndex];
dmFilms.MyQuery2.SQL.Add (QString);
dmFilms.MyQuery2.Open; {open query + display data}
End;
I just know I should see the answer, but I can't. I'm sure someone else can!