Rnd function
-
- 5StarLounger
- Posts: 627
- Joined: 03 Feb 2010, 15:02
Rnd function
How would you use the Rnd function in a query. Is the function called rnd or Rand?
-
- Administrator
- Posts: 78625
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Rnd function
The function is called Rnd. If you use Rnd() in a query, you'll get the same random value in each record. If you want a different value in each record, you must use Rnd([FieldName]) where FieldName is the name of any numeric field in the table(s) that the query is based on.
The values will change each time the query is run or refreshed.
The values will change each time the query is run or refreshed.
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 627
- Joined: 03 Feb 2010, 15:02
Re: Rnd function
How do you get 1500 records say?
-
- Administrator
- Posts: 78625
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Rnd function
I'm sorry, what do you mean? Do you want to draw a random sample from a table with many records?
Best wishes,
Hans
Hans
-
- Administrator
- Posts: 78625
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Rnd function
The idea is as follows:
- Add a column to the query using Rnd([FieldName]) where FieldName is any number field.
- Sort on this field (ascending or descending, it doesn't matter).
- Click in an empty part of the upper half of the query design window.
- Set the Top Values property of the query to 1500 (you can't select this value from the dropdown list but you can type it in yourself).
- Add a column to the query using Rnd([FieldName]) where FieldName is any number field.
- Sort on this field (ascending or descending, it doesn't matter).
- Click in an empty part of the upper half of the query design window.
- Set the Top Values property of the query to 1500 (you can't select this value from the dropdown list but you can type it in yourself).
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 627
- Joined: 03 Feb 2010, 15:02
Re: Rnd function
Thanks. That is what I need...