title: Function with Variant Parameter
body: <p>I created a function to Refresh a Query with Parameters, and then Locate a Specific field .</p>
  
  <pre><code>function RefreshQuery(AQuery : TADOQuery; AField : string; AValue : integer; AParam : string; AParamValue : Variant) : boolean; overload;
  </code></pre>
  
  <p>When the AValue is integer it works , when I change it to Variant</p>
  
  <p><strong>I get a List Index Out of Bounds 1699364 error</strong> .</p>
  
  <p>The Function itself looks like this :</p>
  
  <pre><code>function RefreshQuery(AQuery : TADOQuery; AField : string; AValue : integer; AParam : string; AParamValue : Variant) : boolean; overload;
  var AfterOpen,AfterScroll,BeforeOpen : TDataSetNotifyEvent;
      AList : TStringList;
      i : integer;
  begin
    result:=false;
  
    AfterOpen := AQuery.AfterOpen;
    AfterScroll := AQuery.AfterScroll;
    BeforeOpen := AQuery.BeforeOpen;
  
    AQuery.AfterOpen:=nil;
    AQuery.AfterScroll:=nil;
    AQuery.BeforeOpen:=nil;
  
    AList := TStringList.Create;
    AList.Delimiter:=';';
    AList.DelimitedText:=AParam;
  
    if AQuery.Active then AQuery.Close;
  
    if AList.Count = 1 then
      AQuery.Parameters.ParamByName(AList[i]).Value:=AParamValue // the error happens here
    else
      for i := 0 to AList.Count-1 do
        AQuery.Parameters.ParamByName(AList[i]).Value:=AParamValue[i];
  
    AQuery.Open;
  
    if not AQuery.Locate(AField, AValue, []) then
      result:=false
    else
      result:=true;
  
    AQuery.AfterOpen:=AfterOpen;
    AQuery.AfterScroll:=AfterScroll;
    AQuery.BeforeOpen:=BeforeOpen;
  
    if Assigned(AQuery.AfterScroll) then
      AQuery.AfterScroll(AQuery);
  
    AList.Free;
  end;
  </code></pre>
  
  <p>I use it like this :</p>
  
  <pre><code>  if   RefreshQuery(CityQuery,'id',CityQueryID.Value,'Active',not(CheckBox1.Checked).ToInteger+2) = false then
    begin
      MessageDlg('blabla!',mtWarning, [mbOK], 0);
      Exit;
    end;
  </code></pre>
  
  <p>In the Above example CityQueryID.Value is of Integer Type . But Sometimes I would like to use String . So I would like to change the Function to work with Variants.</p>