Form - Sort Dropdown by Name

Discuss the database features
Post Reply
jmadero
Posts: 62
Joined: Sun Nov 15, 2009 10:04 pm

Form - Sort Dropdown by Name

Post by jmadero »

Hi All,

Trying to get dropdowns in a form to sort by name instead of by the ID which the corresponding table is sorted by.

DB: https://drive.google.com/file/d/1kCiKTw ... sp=sharing
Form: MyLibrary

Dropdown: Title

Help appreciated.
Bodhi 5.0, LibreOffice 6.0.5.2, and OOo
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Form - Sort Dropdown by Name

Post by Villeroy »

Data properties of a listbox, applies to 99% of all listboxes:
Linked field: the field where the listbox value is written to
Source type: SQL or Query (Query if you don't want to compose the same SQL for many equal listboxes)
Source: Either SELECT "Visible Text", "Primary Key" FROM "Somewhere" ORDER BY "Visible Text" or the name of the query having this statement.
Bound field: 1 which is the second field, the primary key of somewhere. 0 is the visible field.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
UnklDonald418
Volunteer
Posts: 1549
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Form - Sort Dropdown by Name

Post by UnklDonald418 »

On the MyLibrary form document the control labled Title is actually a TextBox. On the Data tab of the Form Properties dialog is a Sort option.
For your Author ListBox, on the Data tab of the Properties: List Box dialog add

Code: Select all

ORDER BY  "AuthorName"
to the List content query.
Since the AuthorName field isn't split into First and Last names the results will be sorted by first names and then last names.
Similarly, you can add ORDERY BY clauses to the Series and Genre list boxes.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
jmadero
Posts: 62
Joined: Sun Nov 15, 2009 10:04 pm

Re: Form - Sort Dropdown by Name

Post by jmadero »

Happy to mark this as solved and open a new related question but just in case it seems appropriate and related so here it goes:

DB: https://drive.google.com/file/d/1kCiKTw ... sp=sharing
Table: MyLibrary
Record #: 8
Title: The Riddle

Observed:
"Books in Series" are not in order based on # in Series, instead they appear to be in order by BookID

Question:
Anyway to make this subform organized by # In Series?

You two have both been amazing and I appreciate all the help.
Bodhi 5.0, LibreOffice 6.0.5.2, and OOo
UnklDonald418
Volunteer
Posts: 1549
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Form - Sort Dropdown by Name

Post by UnklDonald418 »

The Data tab of every Form Properties dialog has a Sort option. As long as the field you need is on the list, that should do it.
The other option would be to create a new query for that SubForm.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
Post Reply