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

# TDataSet.MoveBy

Move the cursor position

## Declaration

Source position: db.pas line 1586

`public function TDataSet.MoveBy(`
`Distance: LongInt`
`):LongInt;`

## Arguments

`Distance` |  | Number of positions the cursor should be moved

## Function result

Number of positions the cursor actually moved

## Description

MoveBy moves the current record pointer with Distance positions. Distance may be a positive number, in which case the cursor is moved forward, or a negative number, in which case the cursor is moved backward. The move operation will stop as soon as the beginning or end of the data is reached. The TDataset.BeforeScroll and TDataset.AfterScroll events are triggered (once) when this method is called. The function returns the distance which was actually moved by the cursor.

## Errors

A negative distance will result in an EDatabaseError exception on unidirectional datasets.

## See also

TDataset.RecNo |  | Current record number
TDataset.BeforeScroll |  | Event triggered before the cursor changes position.
TDataset.AfterScroll |  | Event triggered after the cursor has changed position.

The latest version of this document can be found at lazarus-ccr.sourceforge.net .