We help IT Professionals succeed at work.

Named null value in DBLookupComboBox

lavitz
lavitz asked
on
I have DBLookupComboBox binded to dataset.
Dataset have record with is named 'All' and have key value NULL (id=NULL, name='ALL')
DBLookupComboBox display this record, but i cant select it.

How i can solve this?
Comment
Watch Question

Top Expert 2010
Commented:
You can use another ID value for this record. For example, 0 or -1.

Or you use another component, which allows to select record with id=NULL. For example, JvDBLookupCombo from JVCL: http://jvcl.delphi-jedi.org/
Top Expert 2010

Commented:
You probably did not configure datasource info right for the combo property.
It's kind of there but when you select it it does not display in the combo - right ?

Author

Commented:
Combo display value with null, but i can't select it.
What do you mean 'datasource info' ?
Top Expert 2010

Commented:
dbcombo has properties : datasource,datafield,key field...
You must set these right...

Commented:
more details about your problem would be useful, but without that this should work.

Place DataSource component on your form (Data Access TAB in components palette)
Place one dataset component (depends what you use in your app  TTable, Tquery, ADOTable, ADOQuery,....) on your form.
Place DBLookupComboBox component on your form.

Setup Dataset properties needed to connect dataset to DataBase (connection string if that is ADO data set, or DataBase Name if that is TTable component etc.

Setup Datasource dataset property to dataset you use on your form.

Setup DBLookupComboBox  Datasource property to datasource you use on your form. Setup DBLookupComboBox  Datafield property to field in your dataset you want to show in your DBLookupComboBox.

Top Expert 2010

Commented:
ListSource :YourDataSource;
ListField: YourFieldname;
KeyField: YourFieldname;

These 3 must be set right - only these....

Author

Commented:
i set them.
List Dataset have data.

id     name
--------------------
1     'aaaa'
2     'bbbb'
3     'cccc'
Null   'dddd'

in dblookupcombobox all names are displayed correctly. I can select 'aaaa', 'bbbb', 'cccc'. But I cant select 'dddd'


Top Expert 2010

Commented:
Unfortunatelly, standard dblookupcombobox can't do it.

The simplest way to do what you want is changing ID for 'dddd' to 0 or -1? Is it possible?
Top Expert 2010

Commented:
what is the datatype for 'id' field (number,autoinc...) ???