Here is a function I use to get a 10 character random number that does not exist in my customer table.
DP
DO WHILE .T.
Curnum = RAND()
StrNum = STR(CurNum,12,10)
StrNum = SUBSTR(StrNum,AT(".",StrNum)+1,10)
IF SEEK(StrNum,"Customer")
** Keep trying.
ELSE
EXIT
ENDIF
ENDDO
Live life today - tomorrow will take care of itself.