use locate

Test sample can not work

{$FORM TForm2, Unit2.sfm}                        

uses
  Classes, Graphics, Controls, Forms, Dialogs, DB, DBTables,
   Grids, DBGrids, StdCtrls;             

procedure Button1Click(Sender: TObject);
var
  arr : variant;
begin 
  // test1
  arr:= ['A0001','20'];
  Query1.Locate('cust_code;item_no',arr,[]);  
 
  // test2
  Query1.Locate('cust_code;item_no',['A0001','20'],[]);
end;

begin

end;           


Thanks
chou





Hello,


such construction will create a variant array in variable "arr". You must use SetOf to convert the variant array to a set type:

 Query1.Locate('cust_code;item_no', SetOf(['A0001','20']),[]); 

For empty sets, just use 0 (zero) instead of [].

Hi
   about sample.
//------------------------------------
   {$FORM TForm2, Unit2.sfm}                                

uses
  Classes, Graphics, Controls, Forms, Dialogs, DB, DBTables,
  StdCtrls, Grids, DBGrids;

procedure Button1Click(Sender: TObject);
var                                                     
  sCust_code, sItem_no : string;
  bFind : Boolean;
  Arr :  variant;
begin 
  // test 1
   bFind := Query1.Locate('cust_code;item_no', SetOf(['A0003','20']),0);  // err
 
  // test 2                           
  Arr := SetOf(['A0003','20']);   // ok
  bFind := Query1.Locate('cust_code;item_no', Arr,0);  // err

  // run time error :
  // Invalid argument when evulation function.
 
  if bFind then
     Showmessage('Find'); 
    
    
end;

begin

end;
//---------------------



Thanks

chou


I'm sorry, I got confused with Locate parameters. You must use "SetOf" only in the last parameter, but since you are using 0, that's ok. So this is the correct way to use it:


 bFind := Query1.Locate('cust_code;item_no', ['A0003','20'], 0);  


   it's work.
Thanks

chou