Solved

Tdataset lookup example

Posted on 2004-08-21
6
2,590 Views
Last Modified: 2010-04-05
I am looking for a usage example of the TDataset.lookup method (code snippet).  Thanks!
0
Comment
Question by:billseven
  • 2
6 Comments
 
LVL 22

Accepted Solution

by:
Mohammed Nasman earned 63 total points
ID: 11862512
Hello

  First Paramter is the field you want to search in, second parameter the value, and last parameter the field that you want to have it's value based on search on first parameter

procedure TForm1.Button1Click(Sender: TObject);
var
 V : Variant;
begin
  V := Table1.Lookup('CustNo','1231','Company') ;
  ShowMessage(V);
end;

Remember, Lookup method doesn't move the Pointer to the found record, it's just give you the result, if you would like the pointer to move for the found record, use Located instead of it,

HTH

Regards,
Mohammed
0
 
LVL 12

Assisted Solution

by:esoftbg
esoftbg earned 62 total points
ID: 11862818
download a working example from:
page:        http://www.geocities.com/esoftbg/
  link:        Q_21102337.zip

//....................................

procedure TForm1.Button1Click(Sender: TObject);
var
  V: Variant;
  C: Integer;
  A: String;
begin
  V := Table1.Lookup('Company;State', VarArrayOf(['Blue Sports', 'OR']), 'CustNo;Addr1');
  if (VarType(V) in [varNull]) then
    ShowMessage('Search unsuccessful !')
  else
  begin
    C := V[0];
    A := V[1];
    ShowMessage(IntToStr(C) + #10 + A);
  end;
end;
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 13356440
split points
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
TVirtualStringTree  search using TEdit 7 121
Delphi selector screen 2 80
Convert GUI app into console app for Win32 Env 5 100
creating threads in delphi 1 105
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
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…

810 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