我在学习一个DELPHI的MDI的数据库管理程序,在登录到主窗口后,点击人事管理下的添加新员工时,出现提示: project personnel.exe raised exception class evarianterror with message 'invalid type conversion'.process stopped.
use step or run to continue.
     程序代码如下:
     procedure TF_add.AddInit;
var
  counter:integer;
  id:String;
begin
  With DataModule1 do
  begin
    //生成员工号
    T_counter.Filter:='ID=''P''';
    T_counter.Filtered:=True;
    T_counter.Open;
    counter:=T_counter['COUNTER_VALUE'];
    T_counter.Close;
    id:='00000'+IntToStr(counter);
    id:='P'+Copy(id,length(id)-4,5);
    //增加新记录
    T_add_user.Open;
    T_add_user.Append;
    T_add_user['ID']:=id;
    T_add_user['SEX']:='M';
    T_add_user['STATE']:='T';
    i_passwd.Text:=id;
  end;
end;procedure TF_add.FormCreate(Sender: TObject);
begin
  F_main.M_add.Enabled:=False;
  F_main.TB_add.Enabled:=False;
  Width:=272;
  Height:=469;
  With DataModule1 do
  begin
    if not T_department.Active then T_department.Open;
    if not T_job.Active then T_job.Open;
    if not T_edu_level.Active then T_edu_level.Open;
  end;
  AddInit;
end;
如果把AddInit 注释掉程序就不会出此提示,请问是哪里错了啊!!!
    菜鸟呈上!