请看以下代码:
with frmQueryGeneral.Query1 do
begin
if Memo1.Text <> '' then
begin
if CheckBox1.Checked = true then
begin
Filter := Memo1.Text + ' AND (录单日期 >= '''+DateToStr(DateTimePicker1.Date)+''') AND (录单日期 <''' +DateToStr(DateTimePicker2.Date)+''')';
Filtered := True;
end
else
begin
Filter := Memo1.Text;
Filtered := True;
end;
end
else
begin
if CheckBox1.Checked = true then
begin
Filter := ' (录单日期 >= '''+DateToStr(DateTimePicker1.Date)+''') AND (录单日期 <''' +DateToStr(DateTimePicker2.Date)+''')';
Filtered := true;
end
else
begin
Filter := '';
Filtered := true;
end
end;
frmQueryGeneral.Memo1.Text :=Filter;
end;