Board index » delphi » search on 2 fields using Locate?

search on 2 fields using Locate?

How do I tell Locate to search on 2 fields - how do I separate them?
 

Re:search on 2 fields using Locate?


Quote
Susie Bloor <su...@smartdrive.co.uk> wrote in message

news:SMRT6203880B06@smartdrive.co.uk...
Quote
> How do I tell Locate to search on 2 fields - how do I separate them?

The first parameter of Locate expects a string, so you concatenate the field
names
with a semi-colon and surround them with inverted commas (not []).
The second parameter expects a variant, so to pass two or more values you
need to use a variant array...

var
  A: Variant;
begin
  A := VarArrayCreate([0, 1], varVariant);
  A[0] := 'joe';
  A[1] := 'public';
  Table1.Locate('FirstName;LastName', A, [loCaseInsensitive]);
end;

--
Stephen Brown

Other Threads