想要完成点击form1中菜单中的添加,出现form2,在其中输入数据后,点击ok,记录更新,点击cancel,取消操作。为什么无法实现?
procedure TForm1.add1Click(Sender: TObject);
begin
  if table1.canmodify then
  begin
    if form2.showmodal=mrok then
    begin
      table1.insert;
      table1.fields[0].asinteger:=strtoint(form2.employeeno.text);
      table1.fields[1].asstring:=form2.lastname.text;
      table1.fields[2].asstring:=form2.firstname.text;
      table1.fields[3].asstring:=form2.phoneno.text;
      table1.fields[4].asdatetime:=strtodatetime(form2.hiredate.text);
      table1.fields[5].asinteger:=strtoint(form2.salary.text);
      table1.post;
    end;
  end
  else
  application.messagebox('error!','Can not add a record',mb_ok);
end;