Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cannot write to the record because it is in use (Error 1
Message
From
01/11/2003 12:43:48
 
 
To
31/10/2003 19:15:13
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00844916
Message ID:
00845360
Views:
19
Seems to me your function moves the record point in the table your adding a record to. I'd suggest you use a more robust key routine that uses a lookup table of keys, or change to use GUIDs.

Jim Booth and Steve Sawyer suggested a routine that's classic in Effective techniques. There's also an example in the solutions.
OPEN DATABASE HOME() + "Samples\Tastrade\Data\tastrade"
MODIFY procedure
Look for the newid() function.

>Here is that function.
>
>
>FUNCTION NewID()
>	LPARAMETERS tlcKeyField, tlnFieldSize
>	
>	LOCAL lnNumberOfRecords, cx, i, key	 	
>	
>	IF EOF()
>		lnNumberOfRecords = RECCOUNT()
>		IF lnNumberOfRecords = 0
>			RETURN REPLICATE("A", tlnFieldSize)
>		ENDIF
>		GO lnNumberOfRecords
>		cx = &tlcKeyField
>		SKIP 1
>		
>		FOR i = LEN(cx) TO 1 STEP -1
>		 IF !SUBSTR(cx, i, 1) = 'Z'
>		   key = SUBSTR(cx, 1, i-1) ;
>		   + IIF((BETWEEN(ASC(SUBSTR(cx, i, 1)), 48, 121)), ;
>		          CHR(ASC(SUBSTR(cx, i, 1)) +1), "A") ;
>		          + REPLICATE("A", LEN(cx)-i)
>		   i = 1
>		 ENDIF
>		ENDFOR
>		
>		RETURN key
> 	ENDIF
>
>ENDFUNC
>
>
>In DefaultValue function call is: NewID("cid_child", 5)
>
>>Hi, Boban-
>>
>>>I have found out why error happens.
>>
>>Well, you've narrowed down where the source of the problem is...
>>
>>>In a ChildTable table I have field with DefaultValue which is UDF that returns value for that field.
>>>When I issue APPEND BLANK then it goes to that function to retrieve value for field and at the end of function on RETURN lcValue (value for field) error happens.
>>>
>>>When I removed UDF for DefaultValue it works, but I need that function for DefaultValue.
>>>I notice that sometimes error happens and sometimes it let me to append with my value from UDF.
>>
>>It's impossible for me to even guess, not knowing what your UDF does. You'll need to look into that code to see what it does.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform