Sorting within a database grid

I want to be able to have the data listed in a dbGrid be sorted by one (or two) of the fields. The dbGrid's datasource comes from a table which has a master datasource.

I tried specifying the field name I wanted to sort by in the "IndexFieldNames" property, but had a "Index out of range" error.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Did you try SQL?
BadBartAuthor Commented:
The supervisor of the project does not regard SQL very highly as it takes a much longer time to process.

So, I'm only to use things such as Findkey() and FieldByName().
Could you be more specific in telling us what type of database table you have (dbf or paradox) and what are the indexes you have created for the table. This would be more useful in getting a proper solution for your needs.
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

I know this is a stupid question, but i'm going to ask it anyway :

When using IndexFieldNames you have to define as index field names in your table structure. Have you done this. Primary and secondary indexes???

Have fun,
c.u. ZifNab;

Try using
   SomeName : String;
   YourTable.IndexName:= SomeName;
      ---Processing ---
      YourTable.IndexName:= '';

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BadBartAuthor Commented:
Sorry for the delay! Thanks heaps..!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.