(SOLVED) Get value of a field of a highlighted record lazarus / 16-Databases ---------------------------------------------------------------------- Bert_Plitt · 2019-11-13 17:56 I'm a SQLite3 newbee working on a test project (attached).  I've got most things working as desired, but can't figure out how to do the following.  If I highlight one of the records (in the grid) and click btnSelect, I want the value of Field 3 to be copied to the static label.  After the copying is done, ALL the records in the table must remain visible in the grid.  Can anyone suggest code (for the OnClick event) that will assign the value of the highlighted record field into the str variable? Windows 10, Laz 2.0.6, FPC 3.0.4 ---------------------------------------------------------------------- fmc · 2019-11-13 18:17 Not sure if this is what you're looking for. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var    Str: String;begin    // Assign value of highlighted record, "Field 3" to Str    Str:=Query1.Fields[2].AsString; // FIELD 3     txtItem3.Caption:=Str;    // All Records must remain visible in "NAME" grid.end; ---------------------------------------------------------------------- Bert_Plitt · 2019-11-13 21:38 fmc -- YES!  That's exactly what I wanted.  Works like a charm.  I was off in the weeds trying to use SELECT and/or FieldByName.  Thanks. ---------------------------------------------------------------------- fmc · 2019-11-14 02:26 You can use FieldByName and get the same result: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var    Str: String;begin    // Assign value of highlighted record, "Field 3" to Str    Str:=Query1.FieldByName('Field3').AsString;      txtItem3.Caption:=Str;    // All Records must remain visible in "NAME" grid.end; ---------------------------------------------------------------------- Bert_Plitt · 2019-11-15 01:19 fmc -- Yes, that's how I have it in my actual project.  I tried FieldByName when I started, but for some unknown reason Str always contained an empty string.  Evidently I must have changed something in my code because now FieldByName is working.  Thanks for your help. BTW - Do you know how to mark messages as "SOLVED"? ---------------------------------------------------------------------- GAN · 2019-11-15 01:32 Bert_Plitt to mark solved you have to edit your first message. Use Modify button to do it.