View Full Version : random data pulling


rjmccullou
05-03-2000, 09:51 AM
I am wanting to have a report that will pull 100 rows of data from my table randomly.

Hoa Le
05-09-2000, 12:39 PM
First, copy this function to the module section:
-------------
Function Randomizer() As Integer
Static AlreadyPicked As Integer
If AlreadyPicked = False Then Randomize: AlreadyPicked = True
Randomizer = 0
End Function
-------------
Next, in the design view of a select query (with the subject table whose random records to be picked) enter in the query grid:

1)Column 1: YourFieldName
2)Column 2: Rnd(IsNull([YourFieldName])*0+1) - uncheck 'Show' and enter Ascending in Sort
3)Column 3: Randomizer() - In Criteria section: enter 0 - uncheck 'Show'

Finally type in the number of records to be returned in the combo box of the query tool bar, say 100 and click run. This number must not be greater than the number of records in your subject table. Of course, the query can have more than one field from the subject table.

Then you can have a report based on this query.

Lotto Quick pick, anyone?

HTH
Hoa Le

bones01
05-31-2000, 09:04 AM
Is there a way you can have the query ask how many random records you want versus having to put it in the "top value" combo box as a set number. I may only need to look at 50 records one day and 70 records on another day. I dont want to have to go into the query each time to change the "top value".

Do you have any suggestions ?