Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Random keeps giving me same numbers

Status
Not open for further replies.

Zonie32

Technical User
Jan 13, 2004
242
US
Hi all. I have this SQL in a query:

SELECT TOP 6 *
FROM Table1
ORDER BY Rnd([LotNumber]);

This works fine getting me random numbers. But when I close the database and reopen it and run the query again, it keeps giving me the same sets of numbers as it did the time before.

I also have this behind a command button on a form:

Private Sub Command0_Click()
Dim db As DAO.Database
Set db = CurrentDb
db.QueryDefs("Query1").SQL = "SELECT TOP " & RandomPrompt() & _
" * FROM Table1 ORDER BY Rnd([LotNumber]);"
DoCmd.OpenQuery "Query1"
db.Close

End Sub

I can't figure this out. Help please. thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top