Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Error 2072 - Cursor cannot be modified because it contai
Message
From
20/05/2004 04:42:41
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00904961
Message ID:
00905524
Views:
56
>I can reproduce this error w/ out a grid on the form. If you want the sample, let me know, I can send it to you for your viewing enjoyment.
>
>Thanks

Hi Mark,

Based on your repro code, I found the reason for the failure. It is a bug in GETNEXTMODIFIED function. It manifests itself when table buffered append is modified and GETNEXTMODIFIED is called with .T. as the third parameter before the record is saved into buffer.

Here is simplified repro code, I recommend to use workaround 1 or 2.
#define UseWorkAround 0 && change to 1 or 2 or 3

CLEAR 
SET MULTILOCKS ON 
CREATE CURSOR foo (f1 I)

CURSORSETPROP("Buffering",5)
INSERT INTO foo VALUES (1)
INSERT INTO foo VALUES (2)

liRecNo = GETNEXTMODIFIED(0,ALIAS(),.t.)
DO WHILE liRecNo <> 0
   liRecNo = GETNEXTMODIFIED(liRecNo,ALIAS(),.t.)
ENDDO 

* dirty the second record
GO 2
replace f1 WITH f1

IF UseWorkAround = 1
	&& Do not disable rules. There is no reason to disable them in this scenario.
	&& lNoFire essentially means leave the current record dirty, but the next REPLACE
	&& should save it anyway.	
	liRecNo = GETNEXTMODIFIED(0,ALIAS()) 
	?[RECNO],RECNO()
ELSE
	IF UseWorkAround = 2
		* Force the current record to be saved into buffer
		GO RECNO()
	ENDIF

	liRecNo = GETNEXTMODIFIED(0,ALIAS(),.t.)

	IF UseWorkAround = 3
		* just reread the current record
		GO 2 && RECNO() won't help because it returns negative number
	ENDIF
ENDIF 	

* try to modify the first record 
GO 1
replace f1 WITH f1 && <== Cursor cannot be modified because it contains an unsaved record.

RETURN 
Thanks,
Aleksey.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform