yo utilizo una funcion para leer el correlativo cada vez que lo necesito, es esta
Código Delphi
[-]function TobRutinas.LeerCorrelativo(Campo, Accion: String; T: tTable: String;
Var
nReintento: Integer;
Reg: TRegistry;
cOR: String;
begin
nReintento := 1;
if not T.Active then T.Active := True;
T.First;
Result := T.FieldByName(Campo).AsString;
T.Edit;
if Accion = 'I' then T.FieldByName(Campo).AsInteger := T.FieldByName(Campo).AsInteger + 1
else if Accion = 'D' then T.FieldByName(Campo).AsInteger := T.FieldByName(Campo).AsInteger - 1;
T.Post;
end;
tiene unas modificaciones de la original, la cual para poder utilizar debes tener la libreria,
BDEUtil, he aqui la original
Código Delphi
[-]function TobRutinas.LeerCorrelativo(Campo, Accion: String): String;
Var
T: tTable;
nReintento: Integer;
begin
T := tTable.Create(Application);
try
nReintento := 1;
if AbrirTablas(T, cCorrelativo, cCorrelativo_I1) then
begin
Result := StrtoZero(T.FieldByName(Campo).AsString, 12);
EditarRegistro(T);
if Accion = 'I' then T.FieldByName(Campo).AsInteger := T.FieldByName(Campo).AsInteger + 1
else if Accion = 'D' then T.FieldByName(Campo).AsInteger := T.FieldByName(Campo).AsInteger - 1;
While nReintento < 10 do
begin
if GrabarsinMensaje(T) then nReintento := 10
else nReintento := nReintento + 1;
end;
end;
finally
FreeandNil(T);
end;
end;