| | |
|
|
|
Re: Choose random records from table |
| message from Allen Browne on 12 May 2004 |
You need some kind of numeric field that changes from row to row. Perhaps
one of your date fields would do.
1. Create a query into this table.
2. Enter something like this into the Field row:
Rnd(Nz([NameOfYourDateFieldHere], #0:00#)
3. In the Sorting row under this field, choose Ascending.
4. Open the Properties box (View menu).
5. Beside the Top Values property of the query, enter 5000.
6. Open the Immediate Window (Ctrl+G), and enter:
Randomize
The query generates a random number for every row, sorts by that number, and
pulls up the first 5000 records. That is a random selection, in a random
order.
The order is not random unless you issue the Randomize between the time you
open Access and run the query.
The Rnd() function does not actually do anything with the date field, but if
you do not pass a field in, the query optimizer does not bother calling the
function for every row.
|
| =?Utf-8?B?QWxseSBDaGFuZw==?= replied to Allen Browne on 12 May 2004 |
Hi, Allen,
Thanks for your response! I was trying to follow your instructions. I typed what you suggest in the query Like: Rnd(Nz(Date, #0:00#)) in the field row, but Access gave me this message: The expression you entered has an invalid date value. As you can tell, I am pretty novice here and don't know what's the problem. If you can give me more hints, I would really appreciate it.
|
| Allen Browne replied to =?Utf-8?B?QWxseSBDaGFuZw==?= on 13 May 2004 |
Drop "Like:".
Replace "Date" with the name of your field.
[Table1].[Date]
|
|
Archived message: Re: Choose random records from table (Microsoft Access Database)