Title: Using the Lookup method to return values from multiple columns
Question: How do I use the Lookup method to return values from
multiple columns?
Answer:
The result is a variant array -- one index to the array for
every column specified in the KeyValues parameter:
procedure TForm1.Button1Click(Sender: TObject);
var
MyResults: Variant;
MyKeyFields, MyKeyValues: String;
MySearchForValue: Integer;
begin
MyKeyFields := 'CustNo';
MySearchForValue := 1351;
MyReturnColumns := 'Company;Addr1';
MyResults := Table1.Lookup(MyKeyFields, MySearchForValue,
MyKeyValues);
if not VarIsNull(MyResults) then
ShowMessage('Company: ' + MyResults[0] + ' Address: ' +
MyResults[1]);
{ With DBDemos data this returns
"Company: Sight Diver Address: 1 Neptune Lane" }
end;