Ver Mensaje Individual
  #2  
Antiguo 05-12-2007
Avatar de eduarcol
[eduarcol] eduarcol is offline
Miembro Premium
 
Registrado: ago 2003
Ubicación: En los estados Zulia y Merida de Venezuela
Posts: 4.151
Reputación: 25
eduarcol Va por buen camino
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
   //Toma la ruta real de lo datos
   nReintento := 1;
   //Lee el correlativo correspondiente al campo indicado
   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
   //Toma la ruta real de lo datos
   T := tTable.Create(Application);
   try
      nReintento := 1;
      if AbrirTablas(T, cCorrelativo, cCorrelativo_I1) then
      begin
         //Lee el correlativo correspondiente al campo indicado
         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;
__________________
...Yo naci en esta ribera del arauca vibr@d0r
Soy hermano de la espuma,
de la garza, de la rosa y del sol...
Viva Venezuela
Responder Con Cita