Microsoft KB Archive/142397

= BUG: REPLACE with UDF May Cause "Record Is Not Locked" Error =

Article ID: 142397

Article Last Modified on 5/7/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q142397



SYMPTOMS
Using a user-defined function (UDF) that moves the record pointer in the currently selected table with a REPLACE command causes a "Record is not locked" error message. This error occurs if the buffering property is set to 2-Pessimistic record, 3-Optimistic record, or 5-Optimistic table.



WORKAROUND
Set the buffering property to 4-Pessimistic table. This locks the record and updates it after issuing the TABLEUPDATE function.



STATUS
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.



Steps to Reproduce Problem
  Create a program called Test.prg containing the following code: SET MULTILOCKS ON  SET EXCLUSIVE OFF SET DEFAULT TO SYS(2004)+"Samples\Data" OPEN DATABASE Testdata USE Customer =CURSORSETPROP("Buffering",2) GO 5 REPLACE maxordamt WITH mfunc REPLACE maxordamt WITH mfunc =TABLEUPDATE =CURSORSETPROP("Buffering",1)

FUNCTION mfunc ** Moves record from original position oldrec=IIF(EOF,0,RECNO) GO 1 tmp=maxordamt IF oldrec>0 GO oldrec ENDIF RETURN tmp  Run the program. The error "Record is not locked" appears after encountering the second REPLACE command.

