function fun_name(fieldname:String;fieldValue:Variant):TADOQuery
begin
Result:=TADOQuery.Create(Self);
with Result do
Connection:=ADOConnection...
SQL.Clear;
SQL.Add(strSQL); //strSQL is you SQL String
Open;
Locate(FieldName,FieldValue,[]);
end;
end;