(solved) TDataSet.Locate field value from a combobox lazarus / 16-Databases ---------------------------------------------------------------------- bill0287 · 2015-05-04 02:25 This code works, where the field value is hard coded into the locate statement: Code: [Select]if not (dbData.Locate('NAME', DBLookupComboBox.Text,[loCaseInsensitive])) then       MessageDlg('No matching record found.', mtInformation, [mbOK],0); This code does not does work, where I am setting the field value in a combobox: Code: [Select]if not (dbData.Locate(DataFieldComboBox.Text, DBLookupComboBox.Text,[loCaseInsensitive])) then       MessageDlg('No matching record found.', mtInformation, [mbOK],0); ---------------------------------------------------------------------- BitBangerUSA · 2015-05-04 02:43 ah... if not (dbData.Locate(DataFieldComboBox.Text, DBLookupComboBox.Text,[loCaseInsensitive])) then       MessageDlg('No matching record found.', mtInformation, [mbOK],0); should be if not (dbData.Locate(DBComboBox.DataField, DBLookupComboBox.Text,[loCaseInsensitive])) then       MessageDlg('No matching record found.', mtInformation, [mbOK],0); perhaps? you get no compile error? ---------------------------------------------------------------------- bill0287 · 2015-05-04 15:59 not working for me. ---------------------------------------------------------------------- BitBangerUSA · 2015-05-04 16:07 could be this... 'The implementation in TDataset always returns False. It is up to TDataset descendents to implement this method and return an appropriate value.' see http://www.freepascal.org/docs-html/fcl/db/tdataset.html ---------------------------------------------------------------------- rvk · 2015-05-04 16:43 If the first works and the second fails there must be something wrong with the value in DataFieldComboBox.Text. Did you try a Showmessage('|'+DataFieldComboBox.Text+'|'); just before the call? Is the result exactly |NAME| (all caps, no spaces etc). ---------------------------------------------------------------------- BitBangerUSA · 2015-05-04 16:53 silly me. rvk is of course right. sorry bill0287. ---------------------------------------------------------------------- bill0287 · 2015-05-04 17:21 the error was in my code, the statement in the first post works.  Sorry