Combo Box and List Box in LibreOffice Base
LibreOffice Base offers two primary list-selection controls for data entry forms: the Combo Box and the List Box. While both controls present users with a list of selectable items to streamline data input and reduce errors, they serve fundamentally different purposes in relational database design. This guide details the features, configurations, and data source options available for both controls in LibreOffice Base.
The Combo Box Control
A Combo Box combines a standard single-line text input field with a drop-down list.
- Dual Functionality: Users can either select a predefined value from the drop-down menu or manually type an entirely new value into the field.
- Direct Value Storage: The value selected or typed is written directly to the bound database field as plain text or numbers.
- Single-Field Relationship: It cannot display one value (like a name) while storing a different underlying value (like an ID number).
- Ideal Use Case: Autocompleting frequently entered text fields—such as cities, job titles, or shipping methods—where users may occasionally need to enter a novel value not present in the predefined list.
The List Box Control
A List Box restricts the user to selecting only from a predefined set of choices, preventing free-form manual text entry.
- Strict Data Integrity: Users must select an existing item from the list, ensuring consistency across foreign key columns and category fields.
- Bound Fields (Display vs. Stored Value): The most
powerful feature of a List Box is its ability to display human-readable
text (e.g.,
Customer Name) from one table while silently storing a corresponding foreign key (e.g.,CustomerID) into the form’s underlying table. - Presentation Modes: A List Box can be rendered as a drop-down list or as a scrollable multi-line list box showing several choices at once.
- Ideal Use Case: Managing relational data and
foreign keys, such as assigning a product to a specific category,
choosing a vendor, or setting fixed statuses (e.g.,
Pending,Shipped,Delivered).
Available Data Source Types
Both controls can be populated using several data source types accessible via the Data tab in the control’s Properties dialog:
- Valuelist: Static values are entered manually into the control’s properties. Items are separated using Shift+Enter. Best for small, unchanging lists.
- Table: Binds the control directly to an entire table in the database.
- Query: Uses a saved query from the Base document to populate the list.
- SQL: Uses a custom
SELECTstatement. For List Boxes, this typically follows the formatSELECT "DisplayName", "ID" FROM "TableName"where the first column is displayed and the second column is stored (using the Bound field index1). - SQL [Native]: Executes raw SQL directly bypassing the LibreOffice Base parser.
- Tablefields: Dynamically populates the control with the column names of a specified table.
Summary of Differences
| Feature | Combo Box | List Box |
|---|---|---|
| Custom User Input | Allowed | Not Allowed |
| Value Mapping (Display vs. Store) | No (Stores displayed text) | Yes (Displays text, stores ID/Key) |
| Primary Role | Data entry shortcut / Autocomplete | Relational data integrity / Foreign keys |
| Selection Type | Drop-down only | Drop-down or scrollable list |