for i:=0 to dstemp.FieldCount-1 do
      begin
          if not ((dstemp.Fields[i].FieldName='工号') or (dstemp.Fields[i].FieldName='部门') ) then
          begin
            if not ds5.Locate('期数',ds1.Fields[i].FieldName,[]) then
            begin
               ShowMessage('此数据库中无 ['+ds1.Fields[i].FieldName+'] 字段');
               Exit;
            end;
          end;      end;

解决方案 »

  1.   

    //在数据集ds5中查找数据集dstmep中除开"工号"及"部门"外,其它字段名记录。
    //如果在ds5中的"期数“列中找不到相关项目,即退出
      

  2.   

    for i:=0 to dstemp.FieldCount-1 do //从dstemp的第一个字段开始到最后一个字段
          begin
              if not ((dstemp.Fields[i].FieldName='工号') or (dstemp.Fields[i].FieldName='部门') ) then //如果字段名不等于“工号”或者“部门”
              begin
                if not ds5.Locate('期数',ds1.Fields[i].FieldName,[]) then //在ds5中的“期数”列中查找值为Fields[i].FieldName的记录 
                begin
                   ShowMessage('此数据库中无 ['+ds1.Fields[i].FieldName+'] 字段');
                   Exit; //找不到相关的记录,提示并退出循环
                end;
              end;      end;