Solved

Tdataset lookup example

Posted on 2004-08-21
6
2,414 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:
mnasman earned 63 total points
Comment Utility
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
Comment Utility
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:mnasman
Comment Utility
split points
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Delphi 2010 Export to pdf 2 249
Help to pass a value through a function 2 64
loading dll from external path 1 197
delphi exception 7 58
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

743 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now