22 17934
Assuming you have a primary key field named MyID, try:
SELECT * FROM MyTable ORDER BY Rnd(MyTable.MyI D);
The Rnd() does not actually do anything with the primary key, but if you
don't pass it in, the query optimizer is too intelligent and doesn't bother
calling the function again on every row.
Don't forget to issue a Randomize at the start of your session.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Nhmiller" <nh******@aol.c omnojunk> wrote in message
news:20******** *************** ****@mb-m19.aol.com... Is there a way to do this? Thanks.
Neil Cat Paintings At Carol Wilson Gallery http://www.carolwilsongallery.com
>Assuming you have a primary key field named MyID, try: SELECT * FROM MyTable ORDER BY Rnd(MyTable.MyI D);
The Rnd() does not actually do anything with the primary key, but if you don't pass it in, the query optimizer is too intelligent and doesn't bother calling the function again on every row.
Don't forget to issue a Randomize at the start of your session.
Can you give me detailed directions, starting with which Object to click on (I
assume it is Query)? Thanks.
Neil
Cat Paintings At Carol Wilson Gallery http://www.carolwilsongallery.com
1. Make sure your table has an AutoNumber primary key.
2. Create a query into this table.
3. In The Field row, enter:
Rnd([xxxx])
replacing "xxxx" with the name of your primary key field.
4. In the Sorting row under this, enter:
Ascending.
5. Uncheck the box under this in the Show row of the grid.
6. View the output of your query.
This will give you the same seriese of results unless you tell Access to
randomize. To do that:
1. Click the Modules tab of the Database window, and click New.
Access opens a new module.
2. Enter:
Public Function Init()
Randomize
End Function
3. Save the module with a name such as basInit. Close.
4. On the Macro tab of the Database window, click New.
Access opens a new macro.
5. In the Action column, choose RunCode.
In the lower pane enter:
Init()
6. Save the macro with the name AutoExec.
The name is important.
7. Restart your database.
Now each time to you open this database, the randomizer will run.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Nhmiller" <nh******@aol.c omnojunk> wrote in message
news:20******** *************** ****@mb-m16.aol.com... Assuming you have a primary key field named MyID, try: SELECT * FROM MyTable ORDER BY Rnd(MyTable.MyI D);
The Rnd() does not actually do anything with the primary key, but if you don't pass it in, the query optimizer is too intelligent and doesn't bother calling the function again on every row.
Don't forget to issue a Randomize at the start of your session.
Can you give me detailed directions, starting with which Object to click on (I assume it is Query)? Thanks.
Neil Cat Paintings At Carol Wilson Gallery http://www.carolwilsongallery.com
>1. Make sure your table has an AutoNumber primary key. 2. Create a query into this table.
3. In The Field row, enter: Rnd([xxxx]) replacing "xxxx" with the name of your primary key field.
4. In the Sorting row under this, enter: Ascending.
5. Uncheck the box under this in the Show row of the grid.
6. View the output of your query.
That all worked. I notice that each time I open the database and click on the
query for the random order, the order is the same. And if I close the query
display of records, and click on the query again, there is a new random order,
and so on. If I reopen the database and start this over again, the sequence of
random order listings is again the same. This still works for me, as I simply
want to mix up the list. However, so I can fully understand how this Rnd
function works, is there a way to get the first display to be a new random
order each time? The second section of your response may be for this. However I
don't want to randomize every time -- I have a second query that puts all the
records in order of entry. In case you're curious, the database is my music CD
collection, and over a period of a couple years, I listen to every CD this way
without spending time pondering about what I feel like hearing. My process was
much more tedious, using a calculator, hitting random keys and multiplying to
generate random numbers. I finally decided to post a message to find a better
way. Thanks.
Neil
Cat Paintings At Carol Wilson Gallery http://www.carolwilsongallery.com
Yes, the 2nd part is the answer.
The Randomize affects only the Rnd() function.
Once it has been issued, the Rnd() is seeded differently for that session.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Nhmiller" <nh******@aol.c omnojunk> wrote in message
news:20******** *************** ****@mb-m06.aol.com... 1. Make sure your table has an AutoNumber primary key.
2. Create a query into this table.
3. In The Field row, enter: Rnd([xxxx]) replacing "xxxx" with the name of your primary key field.
4. In the Sorting row under this, enter: Ascending.
5. Uncheck the box under this in the Show row of the grid.
6. View the output of your query.
That all worked. I notice that each time I open the database and click on the query for the random order, the order is the same. And if I close the query display of records, and click on the query again, there is a new random order, and so on. If I reopen the database and start this over again, the sequence of random order listings is again the same. This still works for me, as I simply want to mix up the list. However, so I can fully understand how this Rnd function works, is there a way to get the first display to be a new random order each time? The second section of your response may be for this. However I don't want to randomize every time -- I have a second query that puts all the records in order of entry. In case you're curious, the database is my music CD collection, and over a period of a couple years, I listen to every CD this way without spending time pondering about what I feel like hearing. My process was much more tedious, using a calculator, hitting random keys and multiplying to generate random numbers. I finally decided to post a message to find a better way. Thanks.
Neil Cat Paintings At Carol Wilson Gallery http://www.carolwilsongallery.com
What goes between the () in the following statements:
Public Function Init()
Init()
Thank you. This will give you the same seriese of results unless you tell Access to randomize. To do that: 1. Click the Modules tab of the Database window, and click New. Access opens a new module.
2. Enter: Public Function Init() Randomize End Function
3. Save the module with a name such as basInit. Close.
4. On the Macro tab of the Database window, click New. Access opens a new macro.
5. In the Action column, choose RunCode. In the lower pane enter: Init()
6. Save the macro with the name AutoExec. The name is important.
7. Restart your database.
Now each time to you open this database, the randomizer will run.
Neil
Cat Paintings At Carol Wilson Gallery http://www.carolwilsongallery.com
Nhmiller wrote: What goes between the () in the following statements: Public Function Init() Init()
Nowt.
--
This sig left intentionally blank
Could not get this to work. Is something to go between the ()? Thanks. This will give you the same seriese of results unless you tell Access to randomize. To do that: 1. Click the Modules tab of the Database window, and click New. Access opens a new module.
2. Enter: Public Function Init() Randomize End Function
3. Save the module with a name such as basInit. Close.
4. On the Macro tab of the Database window, click New. Access opens a new macro.
5. In the Action column, choose RunCode. In the lower pane enter: Init()
6. Save the macro with the name AutoExec. The name is important.
7. Restart your database.
Now each time to you open this database, the randomizer will run.
Neil
Cat Paintings At Carol Wilson Gallery http://www.carolwilsongallery.com
No. Nothing at all.
If you can't get it to work, you can do this instead, every time you open
your database:
1. Press Ctr+G to open the Immediate window.
2. Type:
Randomize
and press Enter
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Nhmiller" <nh******@aol.c omnojunk> wrote in message
news:20******** *************** ****@mb-m14.aol.com... Could not get this to work. Is something to go between the ()? Thanks.
This will give you the same seriese of results unless you tell Access to randomize. To do that: 1. Click the Modules tab of the Database window, and click New. Access opens a new module.
2. Enter: Public Function Init() Randomize End Function
3. Save the module with a name such as basInit. Close.
4. On the Macro tab of the Database window, click New. Access opens a new macro.
5. In the Action column, choose RunCode. In the lower pane enter: Init()
6. Save the macro with the name AutoExec. The name is important.
7. Restart your database.
Now each time to you open this database, the randomizer will run.
Neil Cat Paintings At Carol Wilson Gallery http://www.carolwilsongallery.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jefferis NoSpamme |
last post by:
I have a query that is showing new items in a store based upon their
inventory date. The problem with my Random order sort is that when the
"next" link is pressed, the random function is called again and I may see
the image previously displayed rather than go through the entire new
inventory.
Any suggestions on how to prevent that occurrence?
SELECT *
FROM `Catalog`
|
by: Lad |
last post by:
What is the best( easiest)way how to sort a file?
I have a file where each record consists of 3 fields( 3 words) and I
would like to sort records by the first field( word)in each record.
Any idea?
Thanks for help
Lad
|
by: Paul Evans |
last post by:
Hi,
I've created a datagrid which works fine accept the id field (the primary
key field) comes out in a random order. How do I get the fields to display
sequencially?
Thanks for your time
Paul Evans
|
by: srikanth |
last post by:
please give me any helpful logics for the subject
|
by: InnoCreate |
last post by:
Hi everyone.
I've recently written a classic asp website which uses an MS Access
datasource. I know this is less than an ideal data source as it has
limited functionality. I have a search form on my website which allows
users to define parameters and return results accordingly. The problem
i have is a need to return these results in a random order each time.
With SQLServer i know NEWID() would do the trick - used this many times
before...
| |
by: kevincw01 |
last post by:
Anyone have a clever way to retrieve for example, items 0-29 from an
array of size N>29, in random order? The catch is that I dont want to
print any items more than once and I dont want to miss any.
This is for a tag cloud where I have sorted them by popularity but now
I need to display only the top 30. I do this now but they are in
order of popularity and its not really a 'cloud'. If I could retrieve
the top 30 in some random order,...
|
by: Tuxedo |
last post by:
I'd like to reorganize the third, fourth, fifth and sixth, as well as any
elements thereafter in an array in random order:
var a = new Array('first','second','third','fourth','fifth','sixth','etc')
In other words, the first, second and third element should remain in
position 0, 1 and 2, while the fourth, fifth and sixth, etc. should appear
in random order.
Can anyone recommend a method to do this?
|
by: federicog |
last post by:
I have to create a listing in random order from a few mysql tables.
I can't use ORDER BY RAND() for a few reasons:
- The random order has to change only every 24hs, ie: today it will show rows number 4 2 3 1 and tomorrow 2 3 1 4, but it should be the same all day long.
- I'm dividing the results in pages using LIMIT x, y.
I suppose I would have to save the random order in a mysql table, but how can I order the results based on that...
|
by: dniom |
last post by:
Hi. Can you help me please?
Is there any way to show a unique random item from an array, every time you refresh the page? In other words how do I show the items from an array in random order, one by one, by reloading the page?
Moreover the page have to be refreshed by pressing the "submit" button...
Thats what I achieved so far :) but it doesn't display the UNIQUE array item every time the page is reloaded...
as you may guess :)
<html>...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |