我用windows2000 server+delphi6+sql2000+bde做工资系统,在添加记录时先按“添加”,编辑后,再按“保存”记录,其中有一个字段是取最后一条记录的值加一,使得此字段按顺序加一,由此就存在一个刷新问题,望赐教!!! 代码如下:// “添加”
procedure TRecForm.SpeedButton1Click(Sender: TObject);    
var i:integer;
    noo:string;
    boo:Tbook;
begin
    if not DataT.Table4.Active then
        DataT.Table4.Open;
    if DataT.Table4.RecordCount = 0 then noo:='0';
    if DataT.Table4.RecordCount > 0 then
        Begin
            boo:= DataT.Table4.GetBook;
            DataT.Table4.Last;
            noo:=DataT.Table4.fieldbyname('EmpId').AsString;  //如果连续 添加记录,则noo值不变,原因应是表没有刷新;
            DataT.Table4.GotoBook(boo);
            DataT.Table4.FreeBook(boo);
        End;
    noo:=FloatToStr(StrToInt(noo)+1);
    For i:=1 to 5-Length(noo) do
    begin
            noo:='0'+noo;
    end;
    application.CreateForm(Taddform,addform);
    if AddForm.ShowModal=mrOk then
    begin
        case AddForm.RadioGroup1.ItemIndex of
        0:  begin
                DataT.Table4.Edit;
                DataT.Table4.insert;
            end;
        1:  begin
                DataT.Table4.Next;
                DataT.Table4.Edit;
                DataT.Table4.Insert;
            end;
        2:  begin
                DataT.Table4.Last;
                DataT.Table4.Edit;
                DataT.Table4.Append;
            end;
        end;
    end;
    Dbedit1.SetFocus;
    Dbedit1.Text:=noo;
    RecForm.Caption:='记录管理  记录数为:'+IntToStr(DataT.Table4.RecordCount)+'人';
    AddForm.Release;
end;// “保存”
procedure TRecForm.SpeedButton3Click(Sender: TObject);
begin
try
  try
    with DataT.Table4 do
    begin
      if not active then open;
      //edit;
      Post;
    end;
  except
    Application.MessageBox('数据发生错误!!!请运行<维护>---><数据清理>菜单项!!!','提示框',mb_ok+mb_iconstop);
    abort;
  end;
Finally
  Application.MessageBox('数据成功保存!!!','提示框',mb_ok+mb_iconinformation);
End;
end;