Grabbing random records (access 2003)

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
 
M

Marshall Barton

_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)
 
A

Allen Browne

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]...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top