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

# TDBLookup.GetKeyValue

Gets the value for the key field at the specified ordinal position in the list of values from the lookup dataset.

## Declaration

Source position: dbctrls.pp line 158

`public function TDBLookup.GetKeyValue(`
`ValueIndex: Integer`
`):Variant;`

## Arguments

`ValueIndex` |  | Ordinal position in the list of key values from the lookup dataset.

## Function result

Value for the Key field retrieved from the lookup dataset.

## Description

GetKeyValue is a Variant function used to get a values from an index key field in the linked lookup dataset.

ValueIndex contains the ordinal position in the list of fields defined as key fields in the Field for the linked dataset. When ValueIndex contains a valid position for the list of fields names, the corresponding field value from the lookup dataset is returned. Otherwise, the Null value is used as the return value for the method.

GetKeyField is called from methods in controls which use TDBLookup in their implementation, such as TDBLookupListBox and TDBLookupComboBox.

## See also

TDBLookupListBox |  | Implements a data-aware listbox control with database lookup capabilities.
TDBLookupComboBox |  | TDBLookupComboBox is a data-aware combo-box for examining a lookup table in a database.
TDataSet.Fields
TField.KeyFields
TField.LookupKeyFields