Dblookupcombobox has a null string

I have a question about DBLookupComboBox.

I have a program in which there is a database that I wrote. It has everything, except when I open DBLookupComboBox, it should have a row with a zero value when the user wants to choose nothing. But there is no one. How can I show a null string?

+1
source share
1 answer

You should either add a line that says β€œNothing” or β€œAll” that ever fits. The usual solution is to query UNION, which can be used as a RowSource in a combo box. Union query can be used to add virtual fields.

If the combo contains only unique values, you can say:

SELECT "Nothing" As Description FROM ATable UNION SELECT Description FROM ATable 

UNION removes duplicates, UNION ALL <no, so if there are matching rows, you can say:

 SELECT DISTINCT "Nothing" As Description FROM ATable UNION ALL SELECT Description FROM ATable 

If you want Nothing to be sorted first, you should manipulate a bit and use Nothing or -Nothing, but if you have an ID column or Key, you can get a good look, for example:

 SELECT 0 As ID, "Nothing" As Description FROM ATable UNION SELECT ID, Description FROM ATable 
+1
source

Source: https://habr.com/ru/post/917976/


All Articles