DBLookupComboBox text property lazarus / 16-Databases ---------------------------------------------------------------------- jack · 2012-09-08 22:47 I would like to Use a DBLookupComboBox to maintain a field in one Query "datasource" and get the list of possible values from another Query "listSource".  As it turns out the two queries are against the same column in the same table. And yields a list of all the previously entered values as options/ It works quite well until I need to add a new option. I can type a new option into the edit box on the control but it is discarded and replaced with an empty string.  I see the DBLookupComboBox.Text property but it returns an empty string whenever the edit does not match one of the options in the listsource. Is there a way to get at the typed entry? ---------------------------------------------------------------------- taazz · 2012-09-08 23:42 Quote from: jack on September 09, 2012, 12:47:24 amI would like to Use a DBLookupComboBox to maintain a field in one Query "datasource" and get the list of possible values from another Query "listSource".  As it turns out the two queries are against the same column in the same table. And yields a list of all the previously entered values as options/ that is a weird design. Quote from: jack on September 09, 2012, 12:47:24 amIt works quite well until I need to add a new option. I can type a new option into the edit box on the control but it is discarded and replaced with an empty string.  I see the DBLookupComboBox.Text property but it returns an empty string whenever the edit does not match one of the options in the listsource. Is there a way to get at the typed entry? No there is no way to accomplish that with a dblookupcombobox. A dblookupcombobox has been designed to enforce a master/detail relationship farther more it is designed to select a value looking at different fields than the key field eg data source = invoice data field = custID list source = customers table list field = customer full name key field = customerID by selecting a customer name the lookup combo box will place the customerID in the invoice.CustID field you can't use its editor to select a value that does not exists because it can't much it to the customerID field wasn't designed for free form editing. You can use a dbcombobox but you have to manually populate with the values you want to choose from and you have to use the values that are going to inserted in the field you can't populate it with customer name link it to custid you will a number of errors. here is a procedure that given a dbcombobox a listdataset (not datasource) and the field's name it will populate the the combobox for you. Code: [Select]procedure PopulateComboBox(aCombo:TDBComboBox; ListDataset:TDataset; ListFieldName:string); var   bkmark : TBookmark;   fld    : TField; begin   ListDataset.DisableControls;   try     fld := ListDataset.FieldByName(ListFieldName);     bkmark:= ListDataset.GetBookmark;     ListDataset.First;     repeat       aCombo.Items.Add(fld.AsString);       ListDataset.Next;     until ListDataset.EOF;   finally     ListDataset.GotoBookmark(bkmark);     ListDataset.FreeBookmark(bkmark);     ListDataset.EnableControls;   end; end;          regards ---------------------------------------------------------------------- jack · 2012-09-09 18:25 Thank you all for your input.