Ask Your Question
0

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

asked 2019-01-11 17:33:56 +0200

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!

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2019-01-11 18:11:22 +0200

Ratslinger gravatar image

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

edit flag offensive delete link more

Comments

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!

Inkblotr gravatar imageInkblotr ( 2019-01-11 21:51:23 +0200 )edit

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?

Inkblotr gravatar imageInkblotr ( 2019-01-11 21:55:10 +0200 )edit

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.

Ratslinger gravatar imageRatslinger ( 2019-01-11 22:59:19 +0200 )edit

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.

ajlittoz gravatar imageajlittoz ( 2019-01-12 08:06:47 +0200 )edit
0

answered 2019-01-11 18:11:30 +0200

ajlittoz gravatar image

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!

edit flag offensive delete link more

Comments

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

Inkblotr gravatar imageInkblotr ( 2019-01-11 21:45:33 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-01-11 17:33:56 +0200

Seen: 25 times

Last updated: Jan 11