如何将 table 中的静态值和记录作为列表项添加到 VBA 中的组合框

How to add BOTH static values and records from a table as list items to a combo box in VBA

我有一个组合框,它从查询中获取其列表项。但是除了这些项目之外,我还需要一个在所有情况下都将存在的静态选项。

我试着用天真的方式这样做:

Private Sub Form_Open(Cancel As Integer)
   Set rst = CurrentDb.OpenRecordset("SELECT ESDNodes.Description, ESDNodes.Sort FROM ESDNodes WHERE (((ESDNodes.parentID) =" & parentID & ")) ORDER BY ESDNodes.Sort")
   Set nextSiblingSelect.Recordset = rst
   nextSiblingSelect.AddItem Item:="Make Last", Index:=0
End Sub

但最终出现了这个 运行 时间错误

The RowSourceType property must be set to 'Value List' to use this method.

这是我半预料到的。

这有什么技巧吗?我想我可以向我的 table 集添加一条虚拟记录并更改查询,但那样会很丑陋,我不喜欢它。

尝试使用 UNION 查询作为组合框 RowSource。也许喜欢:

SELECT Description, Sort FROM ESDNodes UNION SELECT "Make Last", 0 FROM ESDNodes ORDER BY Sort;