Any Values in Query Results

  • Thread starter Thread starter Lamar
  • Start date Start date
L

Lamar

Hello,

In my query results I want to show only 5% of the
results. I know about the TopValue which will show only
the top percentage of the query results.

But is there something that will randomly select 5% of the
query results. So that it will change each time I run the
query. Thanks.
 
Lamar,

You can do it with a little trick, using Access's built-in function Rnd(),
which returns random numbers between 0 and 1. Add a calculated field in the
query grid, with the expression:

RandomID: Rnd([SomeFieldName])

Change SmeFieldName in the expression above to the name of any other field
in your query; it doesn't matter which, this is only in order to force Rnd()
to return a new value in each record. Set the sorting to either Ascendig or
Descending on this calculated field, and you're done!

HTH,
Nikos
 
Back
Top