Создание уникального поля
Procedure TableNewRecord(FieldName: String;
Var DataSet: TDataSet);
Var
NumRec: Integer;
bm: TBookmark;
Begin
with DataSet do
begin
NumRec := Succ(RecordCount);
if State = dsInsert then
Post;
bm := GetBookMark;
DisableControls;
while Locate(FieldName, NumRec, []) and (NumRec > 0) do
Dec(NumRec);
if NumRec = 0 then
begin
NumRec := RecordCount;
while Locate(FieldName, NumRec, []) do
Inc(NumRec);
end;
GotoBookmark(bm);
FreeBookmark(bm);
Edit;
FieldByName(FieldName).AsInteger := NumRec;
Post;
EnableControls;
end;
End;
|
|