有这样的一段代码:
    ……                                  //先前的修改
    Table7.Post;
    Table7.Close;
    Table7.Open;
    j := Table7.RecordCount;             //调试 j = 40 表明有40条记录
    //Table7.DisableControls;
    Table7.First;
    j := 0;
    while not Table7.Eof do
        begin
            Table7.Edit;
            Table7.Fields[14].Value := strtofloat(sContractArray[strtoint(Form2.Table7.Fields[7].Value),3]);
            Table7.Post;
            j := j+1;
            Table7.Next;
        end;
    //调试 j = 22 表明有22条记录
    j := Table7.RecordCount;  //调试 j = 40 表明有40条记录
   // Table7.EnableControls;问题是为什么这程序只遍历22条记录呀?

解决方案 »

  1.   


        //调试 j = 22 表明有22条记录
    showmessage(inttostr(j));//添加这条试试,看显示多少
        j := Table7.RecordCount;  //调试 j = 40 表明有40条记录
       
      

  2.   

    查查Table7.Fields[7].Value中是否有空记录,如有,执行Table7.Post;j统计就有错误,
      而用 j := Table7.RecordCount; 是统计所有的。Form2.Table7.Fields[7].Value只
    执行某个字段
    改为:Table7.First;
        j := 0;
        while not Table7.Eof do
            
    begin
                Table7.Edit;
                Table7.Fields[14].Value := strtofloat(sContractArray[strtoint(Form2.Table7.Fields[7].Value),3]);
                j := j+1;
                Table7.Next;
    end;
    table1.post;
      
      

  3.   

    在 j := Table7.RecordCount; 这句设断点呀 得出 j = 22
    这句结束后就在设断点j = 40
    以lxy13(甜甜)的方法出现了Table7: dataset not in edit or insert mode.
    还有Form2.Table7.Fields[7].Value 都不为空。
      

  4.   

    另外我重写了一次:
    Table7.First;
        j := 0;
        while not Table7.Eof do
            
    begin
                Table7.Edit;
                Table7.Fields[14].Value := strtofloat(sContractArray[strtoint(Table7.Fields[7].Value),3]);
                j := j+1;
                Table7.Next;
    end;
    table7.post;在 table7.post;设断点,j = 22,接着出现了Table7: dataset not in edit or insert mode