The example below uses the
Lookup method to search the sample Paradox table Customer. The search is based on two fields: Company and State. The search is also based on the following two values in these two fields: "Blue Sports" and "OR". For the search to be successful, there must be a record where the Company field contains the value "Blue Sports" AND the field State contains "OR". If either criteria is not met, the search is unsuccessful (such a record does exist in this table, so the search will be successful). The values of the CustNo and Addr1 fields are returned by the execution of the
Lookup method. If the search is unsuccessful, the VarType function applied to the returned variant array returns varNull.
Código Delphi
[-]
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 not (VarType(V) in [varNull]) then begin
C := V[0];
A := V[1];
ShowMessage(IntToStr(C) + #10 + A);
end
else
ShowMessage('Search unsuccessful!');
end;