>>Hi Gang!
>>
>>Question..... I am having a brain fart here......
>>
>>I have in the Application a record I wish to be locked in a table called SS_IO.
>>
>>So, we use RLOCK and lock it. Cool.
>>
>>In another instance of the Application, we have another user who wishes to delete said record in SS_IO.
>>
>>So, when the code runs for the second user to delete the record ( what we do is run the command REPLACE status WITH 2 IN ss_io to filter the record out... it is not really deleted ), the code execution stops and the "Press ESC... record is locked" wait window appears... Cool...
>>
>>But, I'd like to catch this ahead of time when they press the delete button...........
>>
>>I placed this code at the beginning of the Delete button code...
>>
>>
>>*TMT 05/03/2016 Check record to see if it is locked... if so, warn user and then exit....
>>IF ISRLOCKED()
>> MESSAGEBOX('Cannot delete at this time.... the record is locked by another user..... try again later.',0+16,'Cannot delete')
>> RETURN
>>ENDIF
>>
>>
>>I thought ISRLOCKED() would catch this for the second user, but it doesn't. It says .F. for the second, but .T. for the first.
>>
>>Any ideas?
>>
>>Thanks in advance !!
>>Tommy
>
>Check the Remarks section of this command in Help
>
>ISRLOCKED( ) returns a logical true (.T.) if the record is locked by the current application; otherwise a logical false (.F.) is returned.
>
>NoteNote
>ISRLOCKED( ) only returns .T. in the data session that applied the record lock.
>
>So, in reality this function is not very useful as it doesn't detect if the record is locked by someone else.
This tested ok.....
TRY
SET REPROCESS TO 1
REPLACE status WITH 2 IN ss_io FOR status = 5
CATCH
SET REPROCESS TO AUTOMATIC
MESSAGEBOX("Cannot delete the records at this time..... another user has has one of the records open at this time.... try again later",0+16,"Cannot Delete Records")
FINALLY
ENDTRY
SET REPROCESS TO AUTOMATIC
The REPLACE statement attempts to lock all the affected records ( status = 5 ) and lock them.
It can't, since I have one of the affected records locked in another instance of VFP.
So I drop down to CATCH, then finally to the end.
Tommy Tillman A+ NetWork+ MCP