Sign in Join
FPDoc Onlineexperiment

TDataSet.Locate function

Member of TDataSetpublicIn unit DB

Locate a record based on some key values.

Declaration

pascal
function Locate(const KeyFields: string; const KeyValues: Variant; 
 Options: TLocateOptions): Boolean; virtual

Arguments

KeyFields

List of fields, separated by semicolons.

KeyValues

Single value or array of values.

Options

Options to take into account when searching for the record.

Function result

True if a record matching KeyValues is found.

Description

Locate attempts to locate a record in the dataset. There are 2 possible cases when using Locate.

  1. Keyvalues is a single value. In that case, KeyFields is the name of the field whose value must be matched to the value in KeyValues
  2. Keyvalues is a variant array. In that case, KeyFields must contain a list of names of fields (separated by semicolons) whose values must be matched to the values in the KeyValues array

The matching always happens according to the Options parameter. For a description of the possible values, see TLocateOption.

If a record is found that matches the criteria, then the locate operation positions the cursor on this record, and returns True. If no record is found to match the criteria, False is returned, and the position of the cursor is unchanged.

The implementation in TDataset always returns False. It is up to TDataset descendents to implement this method and return an appropriate value.

See also

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.