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.
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.