Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / April 2008

Tip: Looking for answers? Try searching our database.

View a random set of records

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ben - 28 Apr 2008 11:00 GMT
Hi..

I'm trying to get a query to show me all of the records with a specific
reference number, however I want to be able to choose them at random.

If I have 2000 records, each with a unique 'sub record' (with a unique
identifier), how can I choose a random selection of records and sub record,
so that the results show like this???

Reference    Unique ID    Record    Text field
1234        1        Text 1
1234        2        Text 2
1234        3        Text 3
5678        1        Text 1
5678        2        Text 2
5678        3        Text 3
3456        1        Text 1
3456        2        Text 2
3456        3        Text 3

thanks

Ben
Michel Walsh - 28 Apr 2008 14:57 GMT
You can try something like:

SELECT TOP 10 <List Of Fields Or Expressions>
FROM tableName.
WHERE someConditionIfApplicable
ORDER BY RND(SomeNumericalField);

all cap words are to be typed as they are. RND( )  is a VBA function, see
more about it in the help.

I assume you want 10 random records (at most 10) satisfying any conditions
you eventually imposed.

Vanderghast, Access MVP

> Hi..
>
[quoted text clipped - 20 lines]
>
> Ben
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.