Ver Mensaje Individual
  #17  
Antiguo 04-05-2004
Avatar de roman
roman roman is offline
Moderador
 
Registrado: may 2003
Ubicación: Ciudad de México
Posts: 20.269
Reputación: 10
roman Es un diamante en brutoroman Es un diamante en brutoroman Es un diamante en bruto
Pues qué te digo, aún con el truco me gusta más el mío:

Código Delphi [-]
procedure TForm1.combo1Change(Sender: TObject);
  function CondicionCampo(Campo, Valor: String): String;
  begin
    if LowerCase(Valor) = 'todos'
      then Result := '1 = 1'
      else Result := Campo + ' = ' + QuotedStr(Valor);
  end;

var
  whereStr: String;

Begin
  whereStr := CondicionCampo('campo1', combo1.text);
  whereStr := whereStr + ' and ' + CondicionCampo('campo2', combo2.text);
  whereStr := whereStr + ' and ' + CondicionCampo('campo3', combo3.text);
  whereStr := whereStr + ' and ' + CondicionCampo('campo4', combo4.text);
  Query1.SQL.Text := 'select * from tabla where ' + whereStr;
end;

En gustos se rompen géneros
Responder Con Cita