PC SOFT

PROFESSIONAL NEWSGROUPS
WINDEVWEBDEV and WINDEV Mobile

Home → WINDEV 2024 → Multi-Column Sorting with Tables
Multi-Column Sorting with Tables
Started by Jeff Graham, Apr., 30 2005 9:15 PM - 3 replies
Posted on April, 30 2005 - 9:15 PM
We need to be able to sort tables linked to Hyper Files by multiple fields. For example, by Grade and then by Name.
If you use TableSort you get an error saying to create composite keys. However, composite keys for all possible multiple field sorts adds overhead at all times rather just when the table is being used.
If you use a view or an alias, the table cannot be generated in the editor and becomes more tedious and higher maintenance.
Any suggestions for better techniques would be appreciated.
Posted on April, 30 2005 - 11:04 PM
Use queries
Base the table on a query. Then you can either manipulate that query's "sort by" from code and refresh, or you can create a dynamic query in code and set the record source to it. In a similar way you could precook the various queries and save them, then set the record source to them as per need
HTH


http://www.objeKtive.com
Posted on May, 04 2005 - 3:38 AM
Thanks for you reply and my apologies for taking so long to try your suggestion.
I cannot find a way to 'manipulate that query's "sort by" from code'. Can you please give a further hint?
If we create multiple queries, we would have to change the table field links in each case. So that seems to be as tedious as creating a memory table and then updating the file manually.
Thanks,
Jeff
Use queries
Base the table on a query. Then you can either manipulate that query's "sort by" from code and refresh, or you can create a dynamic query in code and set the record source to it. In a similar way you could precook the various queries and save them, then set the record source to them as per need
HTH
Posted on May, 11 2005 - 1:02 PM
Jeff Graham wrote on 04.05.2005 02:38:

Hello Jeff,

Thanks for you reply and my apologies for taking so long to try your suggestion.
I cannot find a way to 'manipulate that query's "sort by" from code'. Can you please give a further hint?
If we create multiple queries, we would have to change the table field links in each case. So that seems to be as tedious as creating a memory table and then updating the file manually.
Thanks,
Jeff

Use queries
Base the table on a query. Then you can either manipulate that query's "sort by" from code and refresh, or you can create a dynamic query in code and set the record source to it. In a similar way you could precook the various queries and save them, then set the record source to them as per need
HTH


First define a query with the WD8 Querydesigner.
Give it a name like qrypTest

Copy the SQL-Syntax form your query into your code.

Create a Table with all needed fields and attac it to your qrypTest


msSQLWhere is string
msSQLOrder is string
msSQL is string


// Do some stuff with the SELECT, WHERE, JOIN, GROUP, ORDER BY, etc
Statements
// I don't know what happend when you add or delete fields.
//
msSQLWhere = "WHERE Table.Field1 = " + True
msSQLOrder = "ORDER by Field2 "

msSQL = "SELECT DISTINCT Table.Field1 AS Field1, Table.Field2 AS Field2
" + ...
msSQLWhere + ...
msSQLOrder


// Using ExecuteSQLQuery() to overwrite the existing query with the self
defined.
IF NOT HExecuteSQLQuery(qrypTest, msSQL) THEN
Error("Error initializing query" +CR+ HErrorInfo())
END



My this would help you.

I'am using this in a litte application for my own.

Take a loo at ExecuteSQLQuery() in the WD8-Helpfile.


Regards
Knut