Board index » delphi » Using Locate method in Delphi 2

Using Locate method in Delphi 2

Is there a recommended way to simulate Paradox's Locate Next function
with Delphi 2? I know that Locate will move the cursor to the first
row in a table when it finds a match to the search criteria, but what
about other records - How do I locate the next and subsequent matches?

Many thanks

 

Re:Using Locate method in Delphi 2


On Thu, 15 Jan 1998 11:54:44 GMT, t...@johnson-delete-.demon.co.uk (Tim

Quote
Johnson) wrote:
>Is there a recommended way to simulate Paradox's Locate Next function
>with Delphi 2? I know that Locate will move the cursor to the first
>row in a table when it finds a match to the search criteria, but what
>about other records - How do I locate the next and subsequent matches?

>Many thanks

Tim,

        Use a TTable and set it's filter property to the desired
records. Then loop through the records with MoveNext();. If you cannot
use the Filter property with the criteria field, use a TQuery instead
and set the SQL to return the desired subset.

                                        Good Luck,
                                                Mike

Re:Using Locate method in Delphi 2


On Thu, 15 Jan 1998 15:06:39 GMT, mksi...@ibm.net (Mike Paschke)
wrote:

Quote
>On Thu, 15 Jan 1998 11:54:44 GMT, t...@johnson-delete-.demon.co.uk (Tim
>Johnson) wrote:

>>Is there a recommended way to simulate Paradox's Locate Next function
>>with Delphi 2? I know that Locate will move the cursor to the first
>>row in a table when it finds a match to the search criteria, but what
>>about other records - How do I locate the next and subsequent matches?

>>Many thanks

>Tim,

Hi :)

You have also Locate function in Delphi, no matter which db you use.

Shalom,

Mladen Kuzminski
BORLAND distribucija
KONTO d.o.o. Pozega, Ured Varazdin
042/231-994, 231-713

mailto:borl...@konto.hr
http://www.konto.hr

LEGALNO JE SIGURNO! BSA g.i.u.
http://www.bsa.hr
mailto:hotl...@bsa.hr

TBDEDataSet.Locate

TBDEDataSet     See also

Searches the dataset for a specified record and makes that record the
current record.

type

  TLocateOption = (loCaseInsensitive, loPartialKey);
  TLocateOptions = set of TLocateOption;

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

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. 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. For example:

with CustTable do

Locate('Company;Contact;Phone', VarArrayOf(['Sight Diver', 'P']),
[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
finds the first record that fulfills at least some initial part of the
KeyValues criteria for record matching. If Options is an empty set, or
if the KeyFields are not 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.

Other Threads