I'm trying to generate a random number for a text box and then check to ensure that the generated number does not already exist in the table.
I have attached a very small file (using ACCESS 2007). The range of generated numbers is very small (1 to 8) to keep the test manageable.
I used the Rnd function in the GotFocus event and then placed the validation check in the BeforeUpdate event. Not sure is this is the proper way to do this.
The index property for the field is set to No in the table design. (I tried setting it to Yes, no duplicates; but that didn't help and led to more problems.)
Long story short: I'm getting duplicates.
I'm hoping to bounce back to the text box and generate another random number automatically. Maybe I need to work in a loop of some kind here.
Any suggestions?
I have attached a very small file (using ACCESS 2007). The range of generated numbers is very small (1 to 8) to keep the test manageable.
I used the Rnd function in the GotFocus event and then placed the validation check in the BeforeUpdate event. Not sure is this is the proper way to do this.
The index property for the field is set to No in the table design. (I tried setting it to Yes, no duplicates; but that didn't help and led to more problems.)
Long story short: I'm getting duplicates.
I'm hoping to bounce back to the text box and generate another random number automatically. Maybe I need to work in a loop of some kind here.
Any suggestions?