Ver Mensaje Individual
  #16  
Antiguo 04-05-2004
Avatar de jachguate
jachguate jachguate is offline
Miembro
 
Registrado: may 2003
Ubicación: Guatemala
Posts: 6.254
Reputación: 27
jachguate Va por buen camino
Cool

Yo lo veo mas sencillo tadavia...

Código Delphi [-]
Var
  YaWhere : Boolean;

  Procedure AddWhere(condicion : String);

  Begin
    if YaWhere Then
      Query1.SQL.Add('and ' + condicion)
    else begin
      Query1.SQL.Add('where ' + condicion);
      YaWhere := True;
    end;
  End;

Begin
  YaWhere := False;
  Query1.SQL.Clear;
  Query1.SQL.Add('Select * from tabla');
  if combo1.Text <> 'todos' then
    AddWhere('campo1 = ' + QuotedStr(combo1.Text));
  if combo2.Text <> 'todos' then
    AddWhere('campo1 = ' + QuotedStr(combo2.Text));
  if combo3.Text <> 'todos' then
    AddWhere('campo1 = ' + QuotedStr(combo3.Text));
  if combo4.Text <> 'todos' then
    AddWhere('campo1 = ' + QuotedStr(combo4.Text));
  Query1.Open;
end;

Hasta luego.

__________________
Juan Antonio Castillo Hernández (jachguate)
Guía de Estilo | Etiqueta CODE | Búsca antes de preguntar | blog de jachguate
Responder Con Cita