Retrieves field values from a record that matches specified search values. Syntax: function Lookup(const KeyFields: String; Description: Call Lookup to retrieve values for specified fields from a record that matches search criteria. KeyFields A string containing a semicolon-delimited list of field names on which to search. KeyValues A variant array containing the values to match in the key fields. To specify multiple search values, pass KeyValues as a variant array as an argument, or construct a variant array on the fly using the VarArrayOf routine. ResultFields A string containing a semicolon-delimited list of field names whose values should be returned from the matching record. Lookup returns a variant array containing the values from the fields specified in ResultFields. Otherwise it returns a Variant with the value Null, indicating that a matching record was not found. Lookup uses the fastest possible method to locate matching records. If the search fields in KeyFields are indexed, Lookup uses the index. Otherwise Lookup creates a filter for the search. Delphi 7 and prior has poor support for int64 values in variant type. This means that you'll be unable to use Locate and similar methods with such fields. Lookup fields and master-detail tables will not work properly too because of their dependence on Locate method. Please update your IDE to BDS 2006 (or later) or don't use BIGINT and UNSIGNED INT datatypes for keys and indexes if you need to use them in lookup fields. Also you can't use variant-style properties (FieldValues, AsVariant and so on) with such fields. See also: Locate method |