Re: go back to database record

Posted by webmaster Guido on November 30, 2010

In Reply to go back to database record posted by Jose C P15709 on November 29, 2010

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

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;

This works for any kind of "dataset" (Table1 in this example), DBF as well as Paradox, ADO, etc...