you would need to create another table in your database to link the random number to the test:
testKeyID - Primary Key, Auto Number
testKey - the random number will be stored in this column
testID - Foreign Key relation to relate the testKey to the test.
when they purchase the key should be stored in this new table along with the ID the key is for.
On the first page of the test, they should enter the test key. create a recordset that filters the testKey table to see if it is a valid key for that test and only allow them to procede if it is found.