distinct values from a field lazarus / 16-Databases ---------------------------------------------------------------------- Hansvb · 2014-06-19 19:12 I have a dataset and 2 comboboxes. The first combobox list stores all the fieldnames of the dataset. I retrieve the fieldnames in the "on form show" event. When i choose a fieldname in de first combobox i want the second combobox filled with the distinct values of the choosen field. is that possible? ---------------------------------------------------------------------- taazz · 2014-06-19 19:25 sure it is of course everything depends on the dataset and from where it gets its rows. eg is it an sql server or a tbufdataset with in memory data? in both cases it can be but it requires different approaches if there is an sql server with data use a secondary query with a dynamicaly created sql command of the type Select Distinct(fieldname) from table) this will return all the unique values of fieldname in table and you can then use it to feed the combobox with values in the second case create a tstringlist set its sorted property to true and its duplicates property to dupignore after that insert all the field values to the stringlist and then assign that to the combo box strings property. ---------------------------------------------------------------------- Hansvb · 2014-06-27 21:00 Its a test with an access database. i have a query to select items from te database and show them in a dbgrid. the first combox shows the fieldnames off the dataset.Ii would like to use a second combobox in which i show the distinct data from 1 field in the data set. i tried a dblookupcombobox. i am able to get de data from the  fieldname. But i have 2 problems. 1 it shows all data. I just want to see the unique values. 2 when i click on the dblookupcombobox i get a error. The database is not in a insert or edit mode. That is true, i just want to make a filter with the choosen item. ---------------------------------------------------------------------- taazz · 2014-06-27 21:06 1) what is the listsource sql command? 2) make sure that the datasource of the dblookupcombo is empty.