with ADOQuery1 do
begin
close;
SQL.clear;
SQL.add('select distinct 部门 from tablename');//关键查询语句
OPen;
ComboBox1.Clear;
While not EOF do
begin
ComboBox1.Items.Add(FieldByName('部门').AsString);
select * from tablename where 部门 = '''+trim(ComboBox1.text)+'''
首选用adoquery查出部门,并把它加入到combobox中去
adoquery1.sql.add(' select distinct 部门 from tabName');
adoquery1.open;
adoquery1.first;
while not adoquery1.eof do
begin
combobox.items.add(adoquery1.fieldbyname('部门').asstring;
adoquery1.next;
end;
with ADOQuery1 do
begin
close;
SQL.clear;
SQL.add('select distinct 部门 from tablename');//关键查询语句
OPen;
ComboBox1.Clear;
While not EOF do
begin
ComboBox1.Items.Add(FieldByName('部门').AsString);
Next;
end;
end;