Locate

<< Click to Display Table of Contents >>

Navigation:  Apollo VCL Components > Apollo VCL Component Reference > TApolloQuery > TApolloQuery Methods >

Locate

Declaration

function Locate(const KeyFields: String; const KeyValues: Variant; Options: TLocateOptions): Boolean;

Description

Searches the result set of a SELECT  statement for a specified record and makes that record the current record.

Parameters

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 ApolloQuery1 do

 Locate('Company;Contact;Phone',

 VarArrayOf(['Sight Diver', 'P', '408-431-1000']),

 [loPartialKey]);

 

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.

Returns

Locate returns True if it finds a matching record, and makes that record the current one. Otherwise Locate returns False.

Delphi Example

if ApolloQuery1.Locate( 'LAST', 'Smith', [loPartialKey] ) then

 ShowMessage( 'Found' ) 

else

 ShowMessage( 'Not found!' ); 

C++Builder Example

if (ApolloQuery1->Locate( "LAST", "Smith", [loPartialKey] ))

 ShowMessage( "Found" ); 

else

 ShowMessage( "Not found!" ); 

See Also

TApolloTable.Locate