go back to database record

Question

I have a dbgrid that is connected to a table. When the user clicks on a button, every record of table is updated with a value, of course at end the last record is selected in the grid. How can I go back to original record?

Answer

This can be done with a Delphi TBookMark object. Here's a Delphi source code example:

procedure TForm1.Button1Click(Sender: TObject);
var
  BookMark1: TBookMark;
begin
  // Save original position:
  BookMark1:= Table1.GetBookmark;
  // Operations that change position in Table1
  // ...
  // Finally, return to original position:
  Table1.GotoBookmark(BookMark1);
  Table1.FreeBookmark(BookMark1);
end;