Solved

rand() in access 2000 ?

Posted on 2003-11-03
2
1,165 Views
Last Modified: 2006-11-17
hi!

i have written a program using mysql.
in a query i´m using order by rand().

now i have to switch to access. but it seems that
there is no rand() function.

how can i handle this?
0
Comment
Question by:StoreMaster
2 Comments
 
LVL 23

Accepted Solution

by:
heer2351 earned 50 total points
ID: 9669772
The msaccess equivalent for rand is rnd
0
 
LVL 77

Expert Comment

by:peter57r
ID: 9669830
There is a rnd() function in Access; but you can't use it in the way you are trying to.

To generate a random field in a query you need to force Access to think that the random number is dependent on a field in the record or else the rnd() value is just calculated once at the start of the query and that value used on all records.

So you can include rnd([anyfield]) and this produces a different result for each record.

You can sort on this value in a query.  Unfortunately, by the time the data is displayed, the random function has triggered again and the numbers have changed so that they appear not to be in order.   If you want to retain the random number sequence you must first write the value to a new field in an update or make-table query and then use another query to present the sorted data.

Pete


0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
unable to save new report from old one 9 31
Office 365 home questions 7 65
A Function to parse a text string 4 37
unable to create table-based data macro in MS ACCESS 2013 11 25
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question