I took no offense, I appreciate the note of thanks. A star is nice but I usually don't get enough online time to respond to a lot of posts so I could never gather enough stars to catch up to some of the other gurus in this forum.
I usually put the above code in a DO WHILE .T. loop if I absolutely need that record locked. This will try 10 times then loop:
SET REPROCESS TO 10
DO WHILE .T.
IF RLOCK() &&... record lock
REPLACE num WITH num + 1
SELECT datafile
IF RLOCK()
REPLACE key_num with keyfile.num
*... other replaces etc.
ENDIF
UNLOCK ALL
EXIT
ELSE
WAIT WINDOW 'Someone else is updating number...' TIMEOUT 2
ENDIF
ENDDO
For the SET REPROCESS command, I took this from the MSDN for Visual Studio:
SET REPROCESS TO nAttempts [SECONDS] | TO AUTOMATIC
TO nAttempts [SECONDS]
Specifies the number of times Visual FoxPro attempts to lock a record or file after an initial unsuccessful attempt. The default value is 0, the maximum value is 32,000.
SECONDS specifies that Visual FoxPro attempts to lock a file or record for nAttempts seconds. It's available only when nAttempts is greater than zero.
For example, if nAttempts is 30, Visual FoxPro attempts to lock a record or file up to 30 times. If you also include SECONDS (SET REPROCESS TO 30 SECONDS), Visual FoxPro continuously attempts to lock a record or file for up to 30 seconds.
TO AUTOMATIC
Specifies that Visual FoxPro attempts to lock the record or file indefinitely (equivalent to setting nAttempts to –2). This clause is similar to setting nAttempts to -1, except that it includes the facility to quit the attempt to lock a record or file.
If an ON ERROR routine isn't in effect and you press ESC in response to the system message, an appropriate alert appears (for example, "Record is in use by another"

. If a function attempts to place the lock, the alert isn't displayed and the function returns false (.F.).
If an ON ERROR routine is in effect and ESC is pressed, the ON ERROR routine is executed. If a function attempts to place the lock, an ON ERROR routine isn't executed and the function returns false (.F.).
Dave S.