Data.DB.TDataSet.MoveBy

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function MoveBy(Distance: Integer): Integer; virtual;

C++

virtual int __fastcall MoveBy(int Distance);

Properties

Type Visibility Source Unit Parent
function public
Data.DB.pas
Data.DB.hpp
Data.DB TDataSet

Description

Moves to another record relative to the active record in the dataset.

Call MoveBy to move the active record by the number of records specified by Distance. 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);



DataSet1->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 Distance subsequent records (if possible), and makes the last record fetched active. If an attempt is made to move past the end of the file, MoveBy sets Eof to true.

If Distance is negative, repeatedly fetches the appropriate number of previous records (if possible), and makes the last record fetched active. If an attempt is made to move past the start of the file, MoveBy sets Bof to true. If the dataset is unidirectional, the dataset raises an EDatabaseError exception when MoveBy tries to fetch a prior record.

Broadcasts information about the record change so that data-aware controls and linked datasets can update.

Returns the 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


Code Examples