RAD Studio |  |

Searching On Partial Keys
See Also
Collapse All

Each time you call SetKey or FindKey, the method clears any previous values in the Fields property. If you want to repeat a search using previously set fields, or you want to add to the fields used in a search, call EditKey in place of SetKey and FindKey.

For example, suppose you have already executed a search of the Employee table based on the City field of the "CityIndex" index. Suppose further that "CityIndex" includes both the City and Company fields. To find a record with a specified company name in a specified city, use the following code:

Copy Code

    Employee.KeyFieldCount := 2;
    Employee.EditKey;
    Employee['Company'] := Edit2.Text;
    Employee.GotoNearest;

Copy Code

    Employee->KeyFieldCount = 2;
    Employee->EditKey();
    Employee->FieldValues["Company"] = Variant(Edit2->Text);
    Employee->GotoNearest();

See Also

Executing a Search with Goto Methods

Executing a Search with Find Methods

Specifying an Index with IndexName

Specifying the Current Record After a Successful Search

Searching on Partial Keys

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!