1

I'm building a form for entering credit/debit transactions, so I have two tables in PostgreSQL

accounts
    id      INTEGER PRIMARY KEY
    name    VARCHAR(128)

ledger
    id      INTEGER PRIMARY KEY
    credit  INTEGER NOT NULL REFERENCES accounts
    debit   INTEGER NOT NULL REFERENCES accounts
    date    DATE NOT NULL
    amount  NUMERIC(8,2)
    text    VARCHAR(128)

I have built a form with a single table control, listing accounts.name, and a subform that references that control for selection.

Inside the subform, there is another table control, showing date, credit, text and amount after matching debit against the selected entry in the master.

So far, that works, however the credit column has the numeric foreign key data inside a numeric field. I'd like to have a dropdown field that allows me to select an account in its place.

Is that possible, or should I go for a fallback solution with a readonly table populated from a query, and separate edit fields in a subsubform?

4

1 回答 1

2

在 LibreOffice 中工作的功能是一个列表框。棘手的是网格/表格控件上的各个字段未显示在表单导航器中。但是,您可以通过进入编辑模式并右键单击网格的标题行/列选择器将网格上的字段类型转换为列表框。在下拉菜单中,选择“替换为”和“列表框”。现在网格中的字段/列是一个列表框。

然后打开“控制”对话框并再次单击网格中适当的标题/列选择器,您刚刚将其更改为列表框。转到“数据”选项卡。在“列表内容类型”下选择“表”和“列表内容”选择外键表。当“绑定字段”的值为“1”时,下拉列表将显示列表源的第一列,并使用第二列的值填充列表框控件中显示的数据源。

为了获得更好的美感,在控制框中的“常规”选项卡中,“下拉”选项中选择“是”。

上述步骤将提供在 UI 中与熟悉的组合框几乎无法区分的功能。您也可以直接在 LO 中尝试“组合框”功能,但对该字段类型的支持不那么强。

于 2015-01-29T14:24:37.303 回答