Using dbListBox to select an item and use its data to search a database lazarus / 16-Databases ---------------------------------------------------------------------- oisinturbitt · 2013-12-03 15:00 I currently have a dbListbox populated by values that a user has searched for. I need to allow the user to select a specific item in this dbListbox to then reverse this process but I have no idea how to allow the user to click on a item and for the program to then take the values from this click as the OnClick function works when the anywhere in the box is clicked and not a specific item. Is this possible to do or will I have to do some other way? Thanks for any help, much appreciated! ---------------------------------------------------------------------- mangakissa · 2013-12-03 15:58 Welcome. A listbox works with items and itemindex. Listbox1.items[Listbox1.itemindex] is the way. If the user has selected an item, the dataset.field should have a selected value, but I'm not shure. To find one or more records in  a table you can use this: Code: [Select]var SelectedItem : string; begin   SelectedItem := Listbox1.items[Listbox1.itemindex];   if Otherdataset.locate(searchfield,vararrayof([SelectedItem]),[]) then    showmessage(Otherdataset.field[0].value)   else     showmessage('nothing found'); end; (this code is wrote without any editor and should be used as example) ---------------------------------------------------------------------- howardpc · 2013-12-03 16:25 oisinturbitt is asking about a DBlistbox, not a standard listbox. You don't need to use the dbListbox's OnClick at all, the functionality is already programmed for you. Provided the dataset you are connected to via your listbox's DataSource property is indexed on the dbListbox's DataField, and is in Edit mode, then selecting an item in the dbListbox's scrollable list of values will update the underlying field value in the dataset's current record.