select random record

  • Thread starter darren via AccessMonster.com
  • Start date
D

darren via AccessMonster.com

I am trying to randomly select a client on a form. The query behind the form
is as follows:

SELECT TOP 1 Rnd([ClientID]) AS Shuffle, tblClients.ClientID, tblClients.
Client
FROM tblClients
ORDER BY Rnd([ClientID]);

However, whenever the form is first opened it always diplays the same record,
when open a second time it always displays the same second record, etc. i.e.
it seems to always 'randomly' select the same ones in the same order???

I have put a requery command in the OnOpen event of the form. What have I
missed?

Thanks in advance?
 
D

darren via AccessMonster.com

Thanks Allen.

It didn't solve it, but it did point me in the right direction.I took the Rnd
out of the query and into a function it seemed Randomize in the form did not
seem to reset the seed for the query.

Public Function fnRndNum(vIgnore As Variant) As Double

Randomize

fnRndNum = Rnd()

End Function

I then used this function in the same query and it worked.


Many Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top