Pues agradecido de nuevo.
Probé con lo que comenta ecfisa pero aunque funciona bien no hace el filtro que necesito ya que muestra, ademas de lo que busco, los registros con campos vacíos.
Al final el código ha quedado como el que os pongo, es con el sistema de engranaje, no se si es lo correcto o no, no entiendo bien la parte que estais debatiendo, pero si que da el resultado que estoy buscando. He añadido hasta 5 edit para adaptarlo y puesto un OR en lugar de AND y ya está operativo.
Código Delphi
[-]procedure TFBuscaCliente.Edit1Change(Sender: TObject);
var bOtraCondicion :boolean;
begin
bOtraCondicion:=false;
with TBuscarCliente do
begin
Close;
SQL.Clear;
SQL.Add('SELECT * FROM CLIENTES');
if ( (Edit1.Text <>'') or (Edit2.Text <>'') or (Edit3.Text <>'') or (Edit4.Text <>'') or (Edit5.Text <>'') ) then
begin
SQL.Add('WHERE');
if Edit1.Text <>'' then
begin
SQL.Add('NOMBRE LIKE :PNOM ');
bOtraCondicion:= true;
Parameters.ParamByName('PNOM').Value:= '%'+Edit1.Text+'%';
end;
if Edit2.Text <>'' then
begin
if bOtraCondicion then
SQL.Add('AND');
SQL.Add('APELLIDOS LIKE :PAPE');
bOtraCondicion:= true;
Parameters.ParamByName('PAPE').Value:= '%'+Edit2.Text+'%';
end;
if Edit3.Text <>'' then
begin
if bOtraCondicion then
SQL.Add('AND');
SQL.Add('DNI LIKE :PDNI');
Parameters.ParamByName('PDNI').Value:= '%'+Edit3.Text+'%';
end;
if Edit4.Text <>'' then
begin
if bOtraCondicion then
SQL.Add('AND');
SQL.Add('PROVINCIA LIKE :PPROV');
Parameters.ParamByName('PPROV').Value:= '%'+Edit4.Text+'%';
end;
if Edit5.Text <>'' then
begin
if bOtraCondicion then
SQL.Add('AND');
SQL.Add('TELEFONO_FIJO LIKE :PTFNO');
Parameters.ParamByName('PTFNO').Value:= '%'+Edit5.Text+'%';
end;
end;
Open;
end;
end;
Gracias de nuevo a todos, con todos los errores que me han surgido en este tiempo he aprendido ademas de lo buscaba otras cosillas, esto es un mundo y todos los días se aprende algo nuevo.
Un abrazo