Searches the dataset for a specified record and makes that record the current record. Syntax: function Locate(const KeyFields: String; Description: Call Locate to search a dataset for a specific record and position the cursor on it. KeyFields is a string containing a semicolon-delimited list of field names on which to search. KeyValues is a variant array containing the values to match in the key fields. If KeyFields lists a single field, KeyValues specifies the value for that field on the desired record. To specify multiple search values, pass a variant array as KeyValues, or construct a variant array on the fly using the VarArrayOf routine. For example: with CusTMySQLTable do Options is a set that optionally specifies additional search latitude when searching on string fields. If Options contains the loCaseInsensitive setting, then Locate ignores case when matching fields. If Options contains the loPartialKey setting, then Locate allows partial-string matching on strings in KeyValues. If Options is an empty set, or if the KeyFields property does not include any string fields, Options is ignored. Locate returns True if it finds a matching record, and makes that record the current one. Otherwise Locate returns False. Locate uses the fastest possible method to locate matching records. If the search fields in KeyFields are indexed and the index is compatible with the specified search options, Locate uses the index. Otherwise Locate 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. |