AnyDAC
ContentsIndexHome
PreviousUpNext
TADDataSet.FindKey Method

Searches for a record containing specified index field values.

Group
Links
Parameters 
Description 
const AKeyValues: array of const 
An open array of values to search. 

True, if key is found. Otherwise - False.

Use FindKey to search for the record in an indexed dataset, using specified index field values. 

AKeyValues is an open array containing field values, called a key. Each value in the key can be a literal, a variable or nil. If the number of values passed in AKeyValues is less than the number of columns in the index used for the search, the missing values are assumed to be NULL. 

If a search is successful, FindKey positions the cursor on the matching record and returns True. Otherwise the cursor is not moved, and FindKey returns False.

function FindKey(const AKeyValues: array of const): Boolean;
ADQuery1.IndexFieldNames := 'F1;F2';
if not ADQuery1.FindKey([100, 'qwe']) then
  ShowMessage('100;qwe is not found');
What do you think about this topic? Send feedback!