To prevent the error, do a DLookup on the the table, looking for your number first. If DLookup returns zero (no matches), then write the number to the table. If DLookup returns a one, it's found a match, so rerun the randomize routine, check for a duplicate again, etc.
Quick rundown:
1)...