How do I use a secondary index to sort records displaying in a form?

I have a 4 field Base table:
ID - Integer/PrimaryKey/AutoValue;
Type_ID - Text fix CHAR;
Type_Name - Text VARCHAR;
Type_Notes - Text VARCHAR

The system created an Index on the PrimaryKey ID field. I created a secondary index on the Type_ID field. I created a simple form to maintain the table records. I need the records to display using the secondary index order, not the system created index order.

I’m a newbie to Base. Thank you in advance!

Hello,

The LO Base documentation will be of much help to someone new → LibreOffice Base Handbook.

You can present records in a sequence of your choice.

  • Edit your form

  • Insure the Form Design toolbar is available

  • Select the Form Navigator icon on the toolbar; this presents a dialog containing the internal forms & their names

  • Right mouse click on the internal form name where you want the change

  • Select Properties

  • On the Data tab, left click the ellipsis to the right of the Sort property

  • On this dialog select the field & sequence you want

  • Close all, save the form change(s)

  • Test for desired result

THANK YOU! This worked! I am using the LO Base Handbook ver 4 but I couldn’t find how to achieve the results I needed but your advice and steps worked perfectly!

If you don’t mind a quick follow-up question - my sense is I did not need to create the secondary index when I created the table. Is that correct?

An index may be helpful in some cases but I am not really sure if you really mean an index or actually a secondary key field. Multiple fields for a key are not usual.

An index is only a kind of cache for accelerating access to the record. Your application should work the same with and without index. The speed is dramatically different if the indexed field is properly chosen, usually one of the record keys. The usefulness of an index depends on how you access your records and on the access frequency/load.

You can do that through editing your query in SQL mode (right-click on the query name and choose relevant menu item). An editor window opens and the SQL language query is presented.

It takes the general form of SELECT <talias>.<field>, … FROM <table> AS <talias>, … WHERE <selection equation> ORDER BY <talias>.<field>, …

The sorting order is defined by the ORDER BY clause telling which fields are used to sort the records. The leftmost field is the first key considered, then equal records are sorted on the second field, etc.

Reading introduction to the SQL language is a valuable help. There are some tips quite well explained in the Base user’s guide.

To show the community your question has been answered, click the ✓ next to the correct answer, and “upvote” by clicking on the ^ arrow of any helpful answers. These are the mechanisms for communicating the quality of the Q&A on this site. Thanks!

Thank you for writing an answer. I’m not using a SQL query. Your answer may be of use to me in the future…