Solved

Locate Function

Posted on 1997-05-26
2
379 Views
Last Modified: 2010-04-04
How - and this is frustrating the  HELL out of me - do you use LOCATE???  I have numerous books and examples and NONE of them explain how to search for multiple strings contained in multiple keywords.

According to the book, locate can search more than one keyfield using more than one keyvalue.  How??

Any help - or even better - sample would be appreciated.

Thanks heaps!
0
Comment
Question by:Stuart_Johnson
2 Comments
 
LVL 6

Author Comment

by:Stuart_Johnson
ID: 1336595
Edited text of question
0
 
LVL 1

Accepted Solution

by:
ozzy earned 100 total points
ID: 1336596
From the delphi 2.0 help:
The Locate method locates and moves to the first record matching the supplied search criteria. KeyFields lists the field or fields you want to search; to search more than one, separate each field name with a semicolon. KeyValues is a variant specifying the field value to match, or an array of field values, if KeyFields lists more than one field. Options lets you specify case-insensitive or partial-key matching.
Locate uses the fastest possible method to locate a matching record; if the dataset has an index on the specified fields that's compatible with case-insensitive matching (if you specify that in Options), the index will be used. Otherwise, Locate sets up a Borland Database Engine filter for efficient searching.

Locate returns True if a matching record could be found or False if no matches were found.

The following code moves the cursor to the first row in the CustTable where the value in the Company column is "Professional Divers, Ltd.":

var
  LocateSuccess: Boolean;
  SearchOptions: TLocateOptions;
begin
  SearchOptions := [loPartialKey];
  LocateSuccess := CustTable.Locate('Company', 'Professional Divers, Ltd.',
    SearchOptions);
end;

If Locate finds a match, the first record containing the match becomes the current record. Locate returns True if it finds a matching record, False if it does not. If a search fails, the current record does not change.

This seems pretty straightforward about how to use multiple keyfileds.  Just seperate them by semicolons.  To search for more than one string, you may have to do multiple searches.

Hope this helps.  I know you could have looked this up, so if you have, don't flame me.  :-)

0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question