B
bear2006
Unregistered / Unconfirmed
GUEST, unregistred user!
小弟是个初学者,用D6+ACCESS做个程序,现在碰到一个问题,哪位大侠帮忙解决一下,
在添加记录后保存,没有问题,但是再添加记录,程序就会显示出前面添加的那条记录,这是啥问题啊,要重新关闭程序,再进去,可以添加,就是每次运行程序只能添加一条记录,再添加的话,就会显示前面添加的记录,这是啥问题啊?
这是我的代码?
ADD:
begin
if pagecontrol1.activepage=tabsheet1 then
begin
Edit2.Visible := true;
Edit3.Visible := true;
Edit4.Visible := true;
Edit5.Visible := true;
dataf.MXBML.Next;
dataf.MXBML.Insert;
action1.Enabled := false;
edit2.SetFocus;
action3.Enabled := true;
Action4.Enabled := true;
end
else IF pagecontrol1.activepage=tabsheet2 then
begin
Edit6.Visible := true;
Edit7.Visible := true;
Edit8.Visible := true;
Edit9.Visible := true;
Edit10.Visible := true;
Edit11.Visible := true;
Edit12.Visible := true;
Edit13.Visible := true;
Edit14.Visible := true;
Edit15.Visible := true;
//dataf.MXBCL.Last;
dataf.MXBCL.Insert;
Action1.Enabled := false;
edit6.SetFocus;
action3.Enabled := true;
Action4.Enabled := true;
end;
end;
SAVE:
begin
if pagecontrol1.activepage=tabsheet1 then
begin
if (edit2.Text <> '') and (edit3.Text <> '') and (edit4.Text <> '') and (edit5.Text <> '') then
begin
Showmessage('Do you think save data!');
edit2.Visible :=false;
edit3.Visible :=false;
edit4.Visible :=false;
edit5.Visible :=false;
DataF.MXBML.Edit;
DataF.MXbMLDepartment.AsString := Edit2.Text;
DataF.MXBMLUser.AsString := Edit3.Text;
dataf.MXBMLMailaccount.AsString := edit4.Text;
dataf.MXBMLPassword.AsString := edit5.Text;
DataF.MXBML.UpdateBatch();
DataF.MXBML.Close;
DataF.mxbml.Open;
Showmessage('update data Successful!');
taxxiform2.DBLookupListBox1.Enabled := true;
taxxiform2.DBLookupListBox1.SetFocus;
Action1.Enabled :=true;
edit1.Enabled := true;
Action3.Enabled :=false;
Action4.Enabled :=false;
end
else
begin
Showmessage('pls input all data!');
edit2.SetFocus;
end;
end
else if pagecontrol1.activepage=tabsheet2 then
begin
edit6.Visible :=false;
edit7.Visible :=false;
edit8.Visible :=false;
edit9.Visible :=false;
edit10.Visible :=false;
edit11.Visible :=false;
edit12.Visible :=false;
edit13.Visible :=false;
edit14.Visible :=false;
edit15.Visible :=false;
DataF.MXBCL.Edit;
DataF.MXBCLName.AsString := Edit6.Text;
DataF.MXBCLType.AsString := Edit7.Text;
DataF.MXBCLBrand.AsString:= Edit8.Text;
DataF.MXBCLModel.AsString:= Edit9.Text;
DataF.MXBCLCPU.AsString := Edit10.Text;
DataF.MXBCLRAM.AsString := Edit11.Text;
DataF.MXBCLHARDDISK.AsString := Edit12.Text;
DataF.MXBCLMotherBoard.AsString := Edit13.Text;
DataF.MXBCLConnection.AsString := Edit14.Text;
DataF.MXBCLDVDRomorCDRom.AsString := Edit15.Text;
DataF.MXBCL.UpdateBatch();
DataF.MXBCL.Close;
DataF.mxbCl.Open;
Showmessage('update data Successful!');
taxxiform2.DBLookupListBox2.Enabled := true;
taxxiform2.DBLookupListBox2.SetFocus;
Action1.Enabled :=true;
Action2.Enabled := true;
Action3.Enabled :=false;
Action4.Enabled :=false;
end
else
begin
Showmessage('pls input all data!');
edit2.SetFocus;
end;
在添加记录后保存,没有问题,但是再添加记录,程序就会显示出前面添加的那条记录,这是啥问题啊,要重新关闭程序,再进去,可以添加,就是每次运行程序只能添加一条记录,再添加的话,就会显示前面添加的记录,这是啥问题啊?
这是我的代码?
ADD:
begin
if pagecontrol1.activepage=tabsheet1 then
begin
Edit2.Visible := true;
Edit3.Visible := true;
Edit4.Visible := true;
Edit5.Visible := true;
dataf.MXBML.Next;
dataf.MXBML.Insert;
action1.Enabled := false;
edit2.SetFocus;
action3.Enabled := true;
Action4.Enabled := true;
end
else IF pagecontrol1.activepage=tabsheet2 then
begin
Edit6.Visible := true;
Edit7.Visible := true;
Edit8.Visible := true;
Edit9.Visible := true;
Edit10.Visible := true;
Edit11.Visible := true;
Edit12.Visible := true;
Edit13.Visible := true;
Edit14.Visible := true;
Edit15.Visible := true;
//dataf.MXBCL.Last;
dataf.MXBCL.Insert;
Action1.Enabled := false;
edit6.SetFocus;
action3.Enabled := true;
Action4.Enabled := true;
end;
end;
SAVE:
begin
if pagecontrol1.activepage=tabsheet1 then
begin
if (edit2.Text <> '') and (edit3.Text <> '') and (edit4.Text <> '') and (edit5.Text <> '') then
begin
Showmessage('Do you think save data!');
edit2.Visible :=false;
edit3.Visible :=false;
edit4.Visible :=false;
edit5.Visible :=false;
DataF.MXBML.Edit;
DataF.MXbMLDepartment.AsString := Edit2.Text;
DataF.MXBMLUser.AsString := Edit3.Text;
dataf.MXBMLMailaccount.AsString := edit4.Text;
dataf.MXBMLPassword.AsString := edit5.Text;
DataF.MXBML.UpdateBatch();
DataF.MXBML.Close;
DataF.mxbml.Open;
Showmessage('update data Successful!');
taxxiform2.DBLookupListBox1.Enabled := true;
taxxiform2.DBLookupListBox1.SetFocus;
Action1.Enabled :=true;
edit1.Enabled := true;
Action3.Enabled :=false;
Action4.Enabled :=false;
end
else
begin
Showmessage('pls input all data!');
edit2.SetFocus;
end;
end
else if pagecontrol1.activepage=tabsheet2 then
begin
edit6.Visible :=false;
edit7.Visible :=false;
edit8.Visible :=false;
edit9.Visible :=false;
edit10.Visible :=false;
edit11.Visible :=false;
edit12.Visible :=false;
edit13.Visible :=false;
edit14.Visible :=false;
edit15.Visible :=false;
DataF.MXBCL.Edit;
DataF.MXBCLName.AsString := Edit6.Text;
DataF.MXBCLType.AsString := Edit7.Text;
DataF.MXBCLBrand.AsString:= Edit8.Text;
DataF.MXBCLModel.AsString:= Edit9.Text;
DataF.MXBCLCPU.AsString := Edit10.Text;
DataF.MXBCLRAM.AsString := Edit11.Text;
DataF.MXBCLHARDDISK.AsString := Edit12.Text;
DataF.MXBCLMotherBoard.AsString := Edit13.Text;
DataF.MXBCLConnection.AsString := Edit14.Text;
DataF.MXBCLDVDRomorCDRom.AsString := Edit15.Text;
DataF.MXBCL.UpdateBatch();
DataF.MXBCL.Close;
DataF.mxbCl.Open;
Showmessage('update data Successful!');
taxxiform2.DBLookupListBox2.Enabled := true;
taxxiform2.DBLookupListBox2.SetFocus;
Action1.Enabled :=true;
Action2.Enabled := true;
Action3.Enabled :=false;
Action4.Enabled :=false;
end
else
begin
Showmessage('pls input all data!');
edit2.SetFocus;
end;