看看你是不是这个意思 ?
procedure TF_demo.Button3Click(Sender: TObject); //模糊查询
begin
adotable1.close;
datasource1.DataSet:=adoquery1;
if trim(Edit1.Text)<>'' then
begin
adoquery1.close;
adoquery1.sql.clear;
adoquery1.SQL.Add('select * from people ');//添加条件
if trim(combobx1.text) = '按班级查询' then //防止输入items属性时,输入空格,可以加trim()命令,下面相同,需要可以自己加。
adoquery1.sql.add(' where 班级字段 like '''+'%'+Edit1.text+'%'+'''');
if combobx1.text = '按专业查询' then
adoquery1.sql.add(' where 专业字段 like '''+'%'+Edit1.text+'%'+'''');
if combobx1.text = '按姓名查询' then
adoquery1.sql.add(' where name like '''+'%'+Edit1.text+'%'+'''');
adoquery1.open;
end;
其它就是找到combobox1的items属性,双击
然后输入
按班级查询
按专业查询
按姓名查询