RAD Studio |  |

Using the MoveBy Method
See Also
Collapse All

MoveBy lets you specify how many rows forward or back to move the cursor in a dataset. Movement is relative to the current record at the time that MoveBy is called. MoveBy also sets the BOF and EOF properties for the dataset as appropriate.

This function takes an integer parameter, the number of records to move. Positive integers indicate a forward move and negative integers indicate a backward move.

Note: MoveBy raises an exception in unidirectional datasets if you use a negative argument.
MoveBy returns the number of rows it moves. If you attempt to move past the beginning or end of the dataset, the number of rows returned by MoveBy differs from the number of rows you requested to move. This is because MoveBy stops when it reaches the first or last record in the dataset.

The following code moves two records backward in CustTable:

Copy Code

    CustTable.MoveBy(-2);

Copy Code

    CustTable->MoveBy(-2);

Note: If your application uses MoveBy in a multi-user database environment, keep in mind that datasets are fluid. A record that was five records back a moment ago may now be four, six, or even an unknown number of records back if several users are simultaneously accessing the database and changing its data.
See Also

Using the First and Last Methods

Using the Next and Prior Methods

Using the Eof and Bof Properties

Marking and Returning to Records

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!