Ver Mensaje Individual
  #6  
Antiguo 19-05-2011
Avatar de Lepe
[Lepe] Lepe is offline
Miembro Premium
 
Registrado: may 2003
Posts: 7.424
Reputación: 31
Lepe Va por buen camino
hace años hice estas rutinas que aún tiro de ellas:
Código Delphi [-]
uses      CheckLst, // marcarchklb
     Classes // QuotedList
;
// y puede que haga falta alguno mas.


// devuelve los items de la siguiente forma : 'aaaa','bbbbb','ccc'
function QuotedList( Items: TStrings):string;
function QuotedListChklb( ctrl:TCheckListBox;const SoloChecked:Boolean = True):string;

....

function QuotedListchklb( ctrl:TCheckListBox;const SoloChecked:Boolean = True):string;
var i:integer;
begin
    result := '';
    with ctrl do
    
    for i:= 0 to Items.Count-1 do
      if SoloChecked then
      begin
        if Checked[i] then
          Result := Result +QuotedStr(Items[i])+',';
      end
      else
        Result := Result +QuotedStr(Items[i])+',';

  if Length(Result)>0 then
    Delete(Result,Length(Result),1); //quito la ultima coma

end;


function QuotedList( Items: TStrings):string;
var i:integer;
begin
    result := '';
    for i:= 0 to Items.Count-2 do
      Result := Result +QuotedStr(Items[i])+',';
    if Items.count > 0 then
      Result := Result + quotedstr(Items[Items.count-1]);
end;

Yo quitaría el parámetro y concatenaría con la salida de quotedList, algo así:
Código Delphi [-]
IBQuery1.SQL.Text := 'SELECT D.DOCTO_CC_ID,D.FOLIO,................ '+
     '.....................................................................................'+
     'left outer join SALDO_CARGO_CC_S ( D.DOCTO_CC_ID,D.FECHA,0,'N') s '+
     'on(D.docto_cc_id=cargo_id) '+
     'WHERE ( D.CONCEPTO_CC_ID = 4 ) and (s.saldo_cargo<>0) and '+
     '(D.clave_cliente in ('+QuotedList(ListBox.Items)+'))';

Saludos
__________________
Si usted entendió mi comentario, contácteme y gustosamente,
se lo volveré a explicar hasta que no lo entienda, Gracias.
Responder Con Cita