[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'DB' (#fcl)

# TDataSet.Bookmark

Get or set the current cursor position

## Declaration

Source position: db.pas line 1724

`public property TDataSet.Bookmark : TBookMark read GetBookmark write GotoBookmark;`

## Description

Bookmark can be read to obtain a bookmark to the current position in the dataset. The obtained value can be used to return to current position at a later stage. Writing the Bookmark property with a value previously obtained like this, will reposition the dataset on the same position as it was when the property was read.

This is often used when scanning all records, like this:

    Var
      B : TBookmarkStr;

    begin
      With MyDataset do
        begin
    	B:=Bookmark;
        DisableControls;
    	try
    	  First;
    	  While Not EOF do
    	    begin
    		DoSomething;
    		Next;
    		end;
    	finally
    	  EnableControls;
    	  Bookmark:=B;
    	end;
    	end;

At the end of this code, the dataset will be positioned on the same record as when the code was started. The TDataset.DisableControls and TDataset.EnableControls calls prevent the controls from receiving update notifications as the dataset scrolls through the records, thus reducing flicker on the screen.

Note that bookmarks become invalid as soon as the dataset closes. A call to refresh may also destroy the bookmarks.

## See also

TDataset.DisableControls |  | Disable event propagation of controls
TDataset.EnableControls |  | Enable event propagation of controls