Lookup question lazarus / 16-Databases ---------------------------------------------------------------------- daveinhull · 2019-02-27 13:31 Hi, I'm trying to use the Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  function Lookup(const KeyFields: string; const KeyValues: Variant; const ResultFields: string): Variant;function with 2 fields. According to the help file: QuoteKeyFields can be a single field name or a semicolon-separated list of fields. KeyValue can be a variant or a variant array and the number of items must match the number of fields specified in KeyFields. My KeyField is already 2 DB fields separated by a ';', but I just can't work out how to pass a variant array of two values for the KeyValue parameter (in ? I tried Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   with TRxDBLookupCombo(Sender) do   if ((Text <> '') and (LookupSource.DataSet.lookup(LookupDisplay,[Text,Text],'ID') = Null)) then Could someone point me in the right direction. Thanks ---------------------------------------------------------------------- daveinhull · 2019-02-27 13:37 HI, Ok, I found it in the help file for the Locate funciton, all sorted. Thanks ---------------------------------------------------------------------- wp · 2019-02-27 13:57 In "Locate" you have the same problem: How to assign an array to a variant? Use VarArrayOf from unit variants. Assuming you have a DB with fields "Name" and "FirstName" and you want to find a record of a person named John Smith you would call: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   Dataset.Locate('Name;FirstName', VarArrayOf(['Smith', 'John']), [loCaseInsensitive]); ---------------------------------------------------------------------- madref · 2019-03-04 20:31 I wrote this function once for databases Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unction MLookup(Veld, Tabel, Voorwaarde: string): variant;var mySql: TSQLQuery;begin  mySQl := TSQLQuery.Create(nil);  mySQl.DataBase := Form_RefereeMain.Connect_RefereeDB;  try    mySql.SQL.Text := Format('SELECT %s FROM %s WHERE %s', [veld, tabel, voorwaarde]);    mySql.Open;//    Result := mySQL.Fields[0].AsVariant;    Result := MySQL.Fields[0].Value;  finally    MySql.Free;  end;end;     // MLookup ---------------------------------------------------------------------- Soner · 2019-03-04 21:03 Quote from: madref on March 04, 2019, 09:31:54 pmI wrote this function once for databases Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unction MLookup(Veld, Tabel, Voorwaarde: string): variant;var mySql: TSQLQuery;begin  mySQl := TSQLQuery.Create(nil);  mySQl.DataBase := Form_RefereeMain.Connect_RefereeDB;  try    mySql.SQL.Text := Format('SELECT %s FROM %s WHERE %s', [veld, tabel, voorwaarde]);    mySql.Open;//    Result := mySQL.Fields[0].AsVariant;    Result := MySQL.Fields[0].Value;  finally    MySql.Free;  end;end;     // MLookup  This is not lookup. Lookup searchs in existing dataset(=resultset), you are sending new query to database. ---------------------------------------------------------------------- madref · 2019-03-05 12:04 This is the equivalent from the DLookUp in MS Access