Grabbing random records (access 2003)

  • Thread starter Thread starter _Bigred
  • Start date Start date
B

_Bigred

Using Access 2003

I would like to randomly grab say 10 records from the table that the report
is based on.

How would I go about this?

TIA,
_Bigred
 
_Bigred said:
Using Access 2003

I would like to randomly grab say 10 records from the table that the report
is based on.


Base the report on a query Like:

SELECT TOP 10 f1,f2,f3,...
FROM table
ORDER BY Rnd(posnumfield)

Be sure to use the Randomize statement before opening the
report.

posnumfieldcan be any field that has a positive value in
every record. If you don't have a field like that, use:
Rnd(Abs(anynumfield) + 1)
 
Create this query as the RecordSource for your report:
SELECT TOP 10 * FROM Table1 ORDER BY Rnd(Table1.ID), Table1.ID;

Note that you need to issue a Randomize so that the sequences don't repeat.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

message
news:[email protected]...
 
Back
Top