EPUB | CHM | PDF

TDataSet.Methods.MoveBy

Top Previous Next

Positions the cursor on a record relative to the active record in the dataset.

Syntax:

function MoveBy(Distance: Integer): Integer;

Description:

Call MoveBy to position the cursor on a record relative to the active record in the dataset. Distance indicates the number of records to move. A positive value for Distance indicates forward progress through the dataset, while a negative value indicates backward progress.

For example, the following statement moves backward through the dataset by 10 records:

MoveBy(-10);

MoveBy posts any changes to the active record and:

      • Sets the Bof and Eof properties to False.
      • If Distance is positive, repeatedly fetches subsequent records (if possible), decrementing Distance until it is zero, positions the cursor on the last record fetched, and makes it the active record. If an attempt is made to move past the end of the file, MoveBy sets Eof to True.
      • If Distance is negative, repeatedly fetches previous records (if possible), incrementing Distance until it is zero, positions the cursor on the last record fetched, and makes it the active record. If an attempt is made to move past the start of the file, MoveBy sets Bof to True.
      • Broadcasts information about the record change so that data-aware controls and linked datasets can update.
      • Returns the actual number of records moved. In most cases, Result is the absolute value of Distance, but if MoveBy encounters the beginning-of-file or end-of-file before moving Distance records, Result will be less than the absolute value of Distance.

See also: Example: MoveBy,SelectedIndex,Tag