I.T. Discussion Community!
-Collapse +Expand
Delphi
Search Delphi Group:

Advanced
-Collapse +Expand Delphi To/From
To/FromCODEGuides
-Collapse +Expand Delphi Store
PRESTWOODSTORE

Prestwood eMagazine

August Edition
Subscribe now! It's Free!
Enter your email:

   ► MB LobbyPascal and Delphi Coding BoardDelphi Single User Apps Topic   Print This     

How to change sort to descending?

How to change sort to descending? in Delphi Single User Apps topic (part of our Pascal and Delphi Coding group).

Quick Search: descending   How change   How change sort  
Ron Roper
Melbourne, Australia
I am having problems changing the sort order on a DBgrid at runtime (I am using paradox tables). I have pre-defined an index for each field I wish to sort on (in ascending order).

I can change which column to sort on by clicking in the column title without problems, but changing the ascend/descend order does not work.

I have stepped through my code and the index definition appears to be getting changed correctly but it seems to lose the change when the Indexdefs are updated or the table is reopened. Here is my routine that is called from the OnTitleClick event.

procedure TTimeSeriesForm.Descend(DoDescending: boolean; Column: TColumn);
var
I: Integer;
begin
CatGrid.DataSource.DataSet.DisableControls;
with Datamodule2 do
begin
CSR.Close;
for I := 0 to CSR.IndexDefs.Count - 1 do
if (CSR.IndexDefs.Items.Fields = Column.FieldName) then
begin
if (Not DoDescending) then
CSR.IndexDefs.Items.DescFields := ''
else
CSR.IndexDefs.Items.DescFields := Column.FieldName;
CSR.IndexName := CSR.IndexDefs.Items.Name;
end;
CSR.Open;
end;
CatGrid.DataSource.DataSet.EnableControls;
end;

Thanks RonR
 Posted 18 years ago (Thread Starter)
Comment Quote
About Ron Roper -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
Old Account!
If this is your account, sign in to activate web presence data (sign in quarterly to keep active). Alternatively, you can subscribe to our monthly eMag with a valid email address.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #7283, 5 reply
Thread Started 8/14/2002 11:29:00 PM
View Counter=8021
Last Reply Posted 6/30/2011 5:42:40 AM)
Location=Melbourne, Australia  
Joined=18 years ago   MB Posts=3  
Rick Carter
Cincinnati OH USA
I would be inclined to also create and name at design time descending indexes for each field, and invoke them by name. If you don't do this, I would suggest going into Database Desktop and at least creating one secondary descending index at design time. That will "force" your table to be upgraded to a Paradox 7 table, which may be the step that the BDE is not performing properly at runtime.
I would encourage you not to spend too much time on solutions specific to the BDE and Paradox tables. Delphi 7 is the last version of Delphi that will include the BDE, and it is labeled "deprecated" and will not see further development.
Rick Carter
Chair, Delphi/Paradox SIG
Cincinnati PC Users Group
 Posted 18 years ago
Comment Quote
About Rick Carter -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
Old Account!
If this is your account, sign in to activate web presence data (sign in quarterly to keep active). Alternatively, you can subscribe to our monthly eMag with a valid email address.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #7304 (Level 1.1)  Reply to 7283
Thread Started 8/19/2002 12:00:00 PM
View Counter=2
Location=Cincinnati OH USA  
Joined=19 years ago   MB Posts=518  
Rick Carter
Cincinnati OH USA
I don't mean to sound overly "doom and gloom" as regards the BDE; I've still got a lot of applications with Paradox tables, and I'm counting on being able to use them for a good long time. Microsoft has a history of abandoning data access technologies and forcing users to switch, and ADO and the Jet engine will probably be abandoned before Borland drops all support for the BDE. I wouldn't be in any great hurry to switch table formats. On the other hand, with new code that I write, when possible I avoid BDE API calls and other code that isn't likely to translate well if at some time in the future I move things to a different database engine.
Rick Carter
Chair, Delphi/Paradox SIG
Cincinnati PC Users Group
 Posted 18 years ago
Comment Quote
About Rick Carter -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
Old Account!
If this is your account, sign in to activate web presence data (sign in quarterly to keep active). Alternatively, you can subscribe to our monthly eMag with a valid email address.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #7345 (Level 1.2)  Reply to 7283
Reply Posted 8/22/2002 11:09:00 AM
Location=Cincinnati OH USA  
Joined=19 years ago   MB Posts=518  
Ron Roper
Melbourne, Australia
Thanks Rick for that advice, I created separate descending indexes and it works fine.

I am interested in following the best path regarding the future of the BDE etc. The project I am working on is expected to be around for some time so I do need to use a supported database format. Briefly, it is a single user application using a local database consisting of about 70 separate paradox tables along with all the index files etc. It is a complex highway pavement modelling and lifecycle tool.

I have considered changing it over to an MSAccess database so that I only have one database file instead of over 200, which would also allow easy updating of tables using Access if necessary. I haven't done enough database programming to be sure of the best solution. Can I use MSAccess files without using the BDE?

Regards

Ron Roper
ARRB Transport Research
Melbourne Australia
 Posted 18 years ago (Thread Starter)
Comment Quote
About Ron Roper -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
Old Account!
If this is your account, sign in to activate web presence data (sign in quarterly to keep active). Alternatively, you can subscribe to our monthly eMag with a valid email address.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #7309 (Level 1.3)  Reply to 7283
Reply Posted 8/19/2002 7:08:00 PM
Location=Melbourne, Australia  
Joined=18 years ago   MB Posts=3  
Anonymous Post

hello friends, how do I create indexes for certain fields to be converted into descanding or ascanding if using an access database. I'm having trouble about it. If I open the database via Access can indeed be made discanding directly. But if I create a button click via Delphi 7 I was very difficult. How? for the information friend.
From: msandi808@gmail.com

---
msandi
 Posted 9 years ago
Comment Quote

Post ID #14651 (Level 2) and Parent is 7283
Reply Posted 6/29/2011 7:38:46 PM
Most Recent Post
Daniel Kram
-- UNK

If it is an index, then by default it is automatically ascending.

When selecting the data, include a SORT BY clause and then DESC for descending - it is automatically ascending by default. Here is an example:
SELECT FieldA, FieldB, FieldC FROM Employee ORDER BY FieldB; 
SELECT FieldA, FieldB, FieldC FROM Employee ORDER BY FieldB DESC;

 

 Posted 9 years ago
Comment Quote
About Daniel Kram -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.

Post ID #14652 (Level 1.1)  Reply to 14651 and Parent is 7283
Thread Started 6/30/2011 5:42:25 AM
Location=-- UNK 
Joined=12 years ago   MB Posts=25   KB Posts=4   KB Comments=11  

Revive Thread!

Add a comment to revive this old thread and make this archived thread more useful.

Write a Comment...
Full Editor
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P154A1
Enter key:
Icon: A Post    Thread    Idea    Important!    Cool    Sad    No    Yes    Includes a Link...   
Thread #7283 Counter
8021
Since 4/2/2008

Follow PrestwoodBoards on: 


©1995-2020 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech