Using Locate method in Delphi 2 
Author Message
 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



Wed, 18 Jun 1902 08:00:00 GMT  
 Using Locate method in Delphi 2


Quote:

>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



Wed, 18 Jun 1902 08:00:00 GMT  
 Using Locate method in Delphi 2



Quote:


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


http://www.konto.hr

LEGALNO JE SIGURNO! BSA g.i.u.
http://www.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.



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Transaction Methods in Interbase using Delphi 3.0 -Problems in commit-rollback methods

2. 'Locate' method with filtered dataset

3. ADO Locate method

4. Locate Method newbie question

5. Help using LOCATE with delphi 3.02

6. Locate method - internal error

7. How to use Table.Locate method for more than one fields search

8. HELP!!! error with locate method

9. Problem with MyDataset.Locate Method, D3

10. Locate method with linked tables

11. Help Developer, Locate Method

12. Bug in Locate Method?

 

 
Powered by phpBB® Forum Software