Lock/UnLock registers by code  

Send By: Q3 Team
Web : http://www.q3.nu
Email: dlib@q3.nu
Date: 27/08/99

Tip accessed 645 times

 





Lock the current record:




    procedure TForm1.Button2Click(Sender: TObject);
    begin
     with Table1 do
     begin
       UpdateCursorPos;
       Check(DbiGetRecord(handle,dbiReadLock,nil,nil));
     end;
    end;




Unlock the current record:




    procedure TForm1.Button3Click(Sender: TObject);
    begin
     with Table1 do
     begin
       UpdateCursorPos;
       Check( DbiRelRecordLock(handle,FALSE) );
     end;
    end;



NOTICE: If you want unlock all the record locked, put TRUE in the line:

       Check( DbiRelRecordLock(handle,TRUE) );





Know if the curren record is locked or not:




    procedure TForm1.Button4Click(Sender: TObject);
    var
       Blokeado:LongBool;
    begin
     with Table1 do
     begin
       UpdateCursorPos;
       DbiIsRecordLocked(Handle,Blokeado);
       If Blokeado then ShowMessage('Registro Bloqueado/Locked')
                   else ShowMessage('Registro NO bloqueado/Unlocked')
     end;
    end;



You look well at yourself the help of all these functions, since I don't know that restrictions have regarding the table type that yoy have using.
Dbase allows to have blocked 100 records and Paradox, 255 the rest of types... I don't know.