肯定是 if Table1.RecordCount<>0 then begin .... end; 没有执行。你把BitBtn2.Caption:='保存[&S]';放到if Table1.RecordCount<>0 then外,这个if BitBtn2.Caption='修改[&E]' then里就行了。
当你执行了:if BitBtn2.Caption='修改[&E]' then begin if Table1.RecordCount<>0 then begin .......... BitBtn2.Caption:='保存[&S]'; {exit;}括号内的应加入. end; end;后,BitBtn2.Caption又变成了'保存[&S]',于是会接着执行你下面的代码,这样BitBtn2.Caption又变成了'修改[&E]',应该在BitBtn2.Caption:='保存[&S]';这句代码后加一句exit;让程序跳出.
if BitBtn2.Caption='修改[&E]' then begin if Table1.RecordCount<>0 then begin ........ end; end;/////// /////////////逻辑错误。 if BitBtn2.Caption='保存[&S]' then begin .........-------------------->>>>>>>>>>>>>>>>>>>>>> if BitBtn2.Caption='修改[&E]' then begin if Table1.RecordCount<>0 then begin .............. end; end else if BitBtn2.Caption='保存[&S]' then begin Table1.Edit; ..............
if Table1.RecordCount<>0 then
begin
....
end;
没有执行。你把BitBtn2.Caption:='保存[&S]';放到if Table1.RecordCount<>0 then外,这个if BitBtn2.Caption='修改[&E]' then里就行了。
begin
if Table1.RecordCount<>0 then
begin
..........
BitBtn2.Caption:='保存[&S]';
{exit;}括号内的应加入.
end;
end;后,BitBtn2.Caption又变成了'保存[&S]',于是会接着执行你下面的代码,这样BitBtn2.Caption又变成了'修改[&E]',应该在BitBtn2.Caption:='保存[&S]';这句代码后加一句exit;让程序跳出.
begin
if Table1.RecordCount<>0 then
begin
........
end;
end;///////
/////////////逻辑错误。
if BitBtn2.Caption='保存[&S]' then
begin
.........-------------------->>>>>>>>>>>>>>>>>>>>>>
if BitBtn2.Caption='修改[&E]' then
begin
if Table1.RecordCount<>0 then
begin
..............
end;
end else if BitBtn2.Caption='保存[&S]' then
begin
Table1.Edit;
..............