Find Random Record in Access 2010

I want to click a button on my vocabulary database, so that a random record is shown each time I click.

I could do it if there was an autonumberID, but in this case the unique field is the word itself (Required + Indexed + No Duplicates Allowed)
LVL 24
EirmanChief Operations ManagerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

So why not add an autonumber?  It does not have to replace the unique field as a primary key.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
EirmanChief Operations ManagerAuthor Commented:
So why not add an autonumber?
I will if I have to, but maybe someone will come up with a solution for this situation. It's a very basic database with no relationships.
This solution uses a make table query to create a temp table, based on a select statement from your source table.

It then adds a field and updates it with random numbers, and finally orders the data by the random number so that you can use a Top N query to select however many random records you need:
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

EirmanChief Operations ManagerAuthor Commented:
Thanks mbizup (and well researched), I'm sure that will do the job, but I have decided not to use it, as the code is long and may need to be modified for access 2010.

While I was waiting for responses to roll in I took your advice and added an auto number field and filled it for every record (append query into a dataless table + the autonum field).

So I'm now going for a simpler solution. What do you think of this .....

EDIT: I'm not sure where to use the code
SELECT TOP 5 * FROM [tableName] ORDER BY rnd(INT(NOW*id)-NOW*id)

EDIT2: got it
EirmanChief Operations ManagerAuthor Commented:
My previous comment says it all.
Thanks mbizup.
Glad you got it working.

I thought that the sheer volume of code in the fontstuff article, even though the method works,  actually in itself made a very good point of WHY you might want to simply go the autonumber route.    ;-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.