procedure TForm1.DBNavigator1BeforeAction(Sender: TObject; Button: TNavigateBtn); begin if Button = nbPost then //此处是你的检测代码;若存在则Abort,反之就Exit end;
用SQL语句呀 到表里去找用QUERY或ADOQUERY与表连接select id from 表名 where id = '401'; 如果有数据返回则是存在的啦!
function RecordExists(sId: string): Boolean; begin result := false; //在这里写入判断语句;若已存在运回true; end; ... begin if Button = nbPost then if RecordExists(dgeStore.Fields[0].AsString) then begin ShowMessage('此记录已存在!') if aqStore.State in [dsInsert, dsEdit] then Abort; end; end;
Button: TNavigateBtn);
begin
if Button = nbPost then
//此处是你的检测代码;若存在则Abort,反之就Exit
end;
到表里去找用QUERY或ADOQUERY与表连接select id from 表名 where id = '401';
如果有数据返回则是存在的啦!
begin
result := false;
//在这里写入判断语句;若已存在运回true;
end;
...
begin
if Button = nbPost then
if RecordExists(dgeStore.Fields[0].AsString) then
begin
ShowMessage('此记录已存在!')
if aqStore.State in [dsInsert, dsEdit] then Abort;
end;
end;