Solved

Tdataset lookup example

Posted on 2004-08-21
6
2,744 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Firemonkey webbrowser scrollbars ? 1 57
Microsoft Access 97 and Delphi XE2 9 72
Delphi Firemonkey send email on Android 1 41
Using MMsystem To change audio input 1 17
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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 an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

749 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