The following form method attempts to lock the current row in the form’s primary rowset. If the lock cannot be secured, it displays information about the current lock.

function lockRow( )

   local cMsg 

   form.rowset.parent.session.lockRetryCount := 1 

   do while true 

      if form.rowset.lockRow( ) 

         return true 

      else 

         cMsg = "Locked by: " + form.rowset.fields[ "_DBASELOCK" ].user + chr(13) + ; 

         "since: " + form.rowset.fields[ "_DBASELOCK" ].lock 

         if msgbox( cMsg, "Record is locked by another", 5 + 48 ) == 2 

            return false 

         endif 

      endif 

   enddo 

The lockRetryCount for the rowset’s query’s session is set to 1 so that the lockRow( ) method will try the lock only once before failing. If left at its default value of zero, dBASE Plus would display its own lock failure dialog, which doesn’t display as much information, and retries continuously to get the lock, which you don’t necessarily want to do.

The MSGBOX( ) used is a Retry/Cancel dialog box. The button number, which MSGBOX( ) returns, is 2 if the Cancel button is clicked or the user presses Esc.