Create Master-Detail Forms in LibreOffice Base
Master-detail forms—often called form-subform relationships—allow you to view and manage data from two related tables simultaneously, such as viewing a customer profile alongside all of their associated orders. This guide provides a straightforward, step-by-step walkthrough for building linked master-detail forms in LibreOffice Base, covering both the Form Wizard method and the manual Form Navigator method.
Prerequisites
Before creating a linked form, ensure your database has a defined
relationship: * A Master (Parent) Table containing a
Primary Key (e.g., CustomerID in a Customers
table). * A Detail (Child) Table containing a Foreign
Key (e.g., CustomerID in an Orders table).
Method 1: Using the Form Wizard (Fastest Approach)
The Form Wizard automates the linking process for new forms.
- Launch the Wizard: In your LibreOffice Base main window, click on the Forms section in the left pane, then select Use Wizard to Create Form.
- Select Master Fields: In the Field selection step, choose your master table from the Tables or queries dropdown and move the desired fields to the right pane. Click Next.
- Enable Subform: Check the box labeled Add Subform.
- Choose Subform Mode: Select Subform based on manual selection of fields (or Subform based on existing relation if defined in Tools > Relationships) and click Next.
- Select Detail Fields: Choose your detail table and move the required fields to the right pane. Click Next.
- Link Master and Detail Fields:
- Under First master field, select the primary key
from the master table (e.g.,
CustomerID). - Under First slave field, select the foreign key
from the detail table (e.g.,
CustomerID). - Click Next.
- Under First master field, select the primary key
from the master table (e.g.,
- Arrange Controls: Choose your preferred layout (e.g., Columnar for the master form and As Data Sheet / Grid for the detail subform).
- Save and Finish: Set data entry permissions, apply a style, name the form, and click Finish.
Method 2: Manually Linking a Subform in Design View
If you have an existing form, you can insert and link a detail subform manually.
- Open Form in Edit Mode: Right-click your existing master form and choose Edit.
- Open Form Navigator: Click the Form Navigator icon on the Form Design toolbar.
- Add Subform:
- In the Form Navigator window, right-click
MainForm(or the root form). - Select New > Form. Rename this new entry to
SubForm.
- In the Form Navigator window, right-click
- Configure Subform Data Source:
- Right-click
SubFormin the Form Navigator and select Properties. - Go to the Data tab.
- Set Content type to
TableorQuery. - Set Content to your detail table name.
- Right-click
- Establish the Link:
- In the same Data tab, locate Link master fields and
click the ellipsis button (
...). - Match the parent table’s Primary Key to the child table’s Foreign Key.
- Click OK and close the Form Properties dialog.
- In the same Data tab, locate Link master fields and
click the ellipsis button (
- Add Controls to the Subform:
- Select the
SubFormin the Form Navigator to ensure it is active. - Add controls to your canvas (such as a Table Control / Grid Control for displaying multiple records).
- Follow the control wizard to bind specific fields from your detail table.
- Select the
Testing the Master-Detail Relationship
- Toggle off Design Mode (click the Design Mode On/Off icon on the toolbar).
- Use the navigation bar at the bottom to browse master records.
- The detail subform will instantly update to show only the records corresponding to the active master record.