Можно ли сделать фильтрацию 1 таблицы одновременно с 3 фильтров?
Тоесть, у меня в таблице 3 столбца, далее есть edit.text, чекбокс и комбобокс - у каждого из них есть условия фильтрации для каждого столбца. Так вот, можно ли сделать не прибегая к многочисленным условиям IF чтобы фильтры работали параллельно? Тоесть накладывались друг на друга.
На данный момент для каждого из них у меян примерно такой код:
Код:
if (edit2.Text='') and (checkbox9.Checked=false) and (combobox15.Text<>'') then
begin {if1}
ADOQuery1.Filter:=Format('(Район LIKE ''%s'')',[combobox15.Text]);
ADOQuery1.Filtered:=True;
exit;
end;{if1}
if (edit2.Text<>'') and (checkbox9.Checked=false) and (combobox15.Text<>'') then
begin {if2}
ADOQuery1.Filter:=Format('(Район LIKE ''%s'' and Комнат ''%s'')',[combobox15.Text,edit2.Text]);
ADOQuery1.Filtered:=True;
exit;
end;{if2}
if (edit2.Text='') and (checkbox9.Checked=true) and (combobox15.Text<>'') then
begin {if3}
ADOQuery1.Filter:=Format('(Район LIKE ''%s'' and Этаж<>1)',[combobox15.Text]);
ADOQuery1.Filtered:=True;
exit;
end;{if3}
if (edit2.Text<>'') and (checkbox9.Checked=true) and (combobox15.Text<>'') then
begin {if4}
ADOQuery1.Filter:=Format('(Район LIKE ''%s'' and Комнат ''%s'' and Этаж<>1)',[combobox15.Text,edit2.Text]);
ADOQuery1.Filtered:=True;
exit;
end;{if4} if (edit2.Text='') and (checkbox9.Checked=false) and (combobox15.Text<>'') then
begin {if1-1}
ADOQuery1.Filter:=Format('(Район LIKE ''%s'')',[combobox15.Text]);
ADOQuery1.Filtered:=True;
exit;
end;{if1-1}
if (edit2.Text<>'') and (checkbox9.Checked=false) and (combobox15.Text='Все') then
begin {if2-1}
ADOQuery1.Filter:=Format('(Комнат ''%s'')',[edit2.Text]);
ADOQuery1.Filtered:=True;
exit;
end;{if2-1}
if (edit2.Text='') and (checkbox9.Checked=true) and (combobox15.Text='') then
begin {if3-1}
ADOQuery1.Filter:='Этаж<>1';
ADOQuery1.Filtered:=True;
exit;
end;{if3-1}
if (edit2.Text<>'') and (checkbox9.Checked=true) and (combobox15.Text='Все') then
begin {if4-1}
ADOQuery1.Filter:=Format('(Комнат ''%s'' and Этаж<>1)',[edit2.Text]);
ADOQuery1.Filtered:=True;
exit;
end;{if4-1}
Я думаю есть альтернатива этой грамосткости... Подскажите пожалуйста...