dblookupcombobox有一个空行 [英] dblookupcombobox has a null row
问题描述
我有一个关于DBLookupComboBox的问题。
I have a question about DBLookupComboBox.
我有一个程序,我写了一个数据库。它有一切,除非我打开DBLookupComboBox它必须有一个空值的行,当用户想要选择什么。但是没有一个。
I have a program that has a database I wrote. It has everything, except when I open DBLookupComboBox it must have a row with null value for when user wants to select nothing. But there isn't one. How can I make a null row show up?
推荐答案
您必须添加一行Nothing或All ,永远适合。通常的解决方案是UNION查询,它可以用作组合框的RowSource。联合查询可用于添加虚拟字段。
You must either add a row that says 'Nothing' or 'All', which ever suits. The usual solution is a UNION query, which can be used as the RowSource of the combobox. The Union query can be used to add virtual fields.
如果组合仅包含唯一值,您可以说:
If the combo comtains only unique values, you can say:
SELECT "Nothing" As Description
FROM ATable
UNION
SELECT Description
FROM ATable
UNION消除重复项,UNION ALL <没有,所以如果有匹配的行,你可以说:
UNION eliminates duplicates, UNION ALL< does not, so if there are matching rows, you can say:
SELECT DISTINCT "Nothing" As Description
FROM ATable
UNION ALL
SELECT Description
FROM ATable
想要无排序,你必须拼凑一点,使用无或无,但如果你有一个ID或键列,你可以得到一个很好的排序,如:
If you want "Nothing" to sort first, you must juggle a little and use " Nothing", or "-Nothing", but if you have an ID or Key column you can get a nice sort, like so:
SELECT 0 As ID, "Nothing" As Description
FROM ATable
UNION
SELECT ID, Description
FROM ATable
这篇关于dblookupcombobox有一个空行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!