473,830 Members | 2,160 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Random Records

Access 2000.
I have a field in a table (tbl_data entry) which has a field called Free and
another field called SD (containing 2 options: 5 and 6)
The Free field is a yes/no format.
I'd like to run a query which upon entering a date range ("Enquiry Date")
value -allows the query to choose 170 records (by ticking off the yes/no
field "Free") randomly from tbl_data entry.
Alternatively: It could choose (ticking off the yes/no field "Free) the
first 170 records within the date range entered (choosing the earliest date
and working down the list).
thanks.
Nov 12 '05 #1
1 2872
Assuming your table has a numeric primary key named "ID", you can get 170
random records in the date range with this kind of thing:
SELECT TOP 170 * FROM [tbl_data entry]
WHERE [Enquiry Date] Between #1/31/2004# And #2/29/2004#
ORDER BY Rnd([ID]), ID;

You can then turn it into an Update query (Update on query menu) to update
the Free field to True.

Notes:
1. Issue a Randomize in the Immediate Window Ctrl+G) before running the
query.

2. The Rnd() function does not do anything with the ID field, but if you do
not pass in a changing number, the optimizer does not call the Rnd()
function on every row.

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

"Manton" <sk**@optusnet. com.au> wrote in message
news:40******** **************@ news.optusnet.c om.au...
Access 2000.
I have a field in a table (tbl_data entry) which has a field called Free and another field called SD (containing 2 options: 5 and 6)
The Free field is a yes/no format.
I'd like to run a query which upon entering a date range ("Enquiry Date")
value -allows the query to choose 170 records (by ticking off the yes/no
field "Free") randomly from tbl_data entry.
Alternatively: It could choose (ticking off the yes/no field "Free) the
first 170 records within the date range entered (choosing the earliest date and working down the list).
thanks.

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
6295
by: Keith Griffiths | last post by:
I'm trying to do a search under a set criteria followed by a selection of random entries meeting this criteria. But I don't seem to be able to achieve this. The idea being to search on say subject and then select a random set of records meeting that subject. Any ideas or thought would be helpful. I'm using Access XP to try this out. TIA
3
2402
by: Wim Roffil | last post by:
Hi, When I do a select with a limit I get always the same records. Usually this is the desidered effect. But now I want to do a random select. So every time I do a select I should get a different set of results. What is the best way to achieve this effect?
22
17941
by: Nhmiller | last post by:
Is there a way to do this? Thanks. Neil Cat Paintings At Carol Wilson Gallery http://www.carolwilsongallery.com
4
5172
by: yf | last post by:
A KB article "http://support.microsoft.com/default.aspx?scid=kb;en-us;209599" tells that the maximum number of records that a table may hold if the PRIMARY key data type is set to AUTONUMBER is 4,294,967,295. Suppose the PRIMARY key data type is set to "RANDOM" AutoNumber. Suppose an application (a) successfully INSERTS "X" records, then (b) successfully DELETES "Y" records (X >= Y), then
2
4847
by: IceCube | last post by:
Hello, I would like to select/filter at random 30 records out of an Access-table of 1500 records. I know the option "Top" which gives me the possibility to see the 30 first records of the table The problem is that this option is linked to the way of sorting the table. So you will always select from a very restraint part of the 1500 records. Is there a possibility * to select or sort at random in Access. Maybe there exists an
4
8254
by: Greg Strong | last post by:
Hello All, Is it possible to create multiple random numbers in a query where there are numerous records? I've created a custom function. When I use it in a query it creates the same random number for ALL the records. It appears the function is only getting called once, therefore only one random number is being generated for all the records. I want a different random number for each record. Is this possible, or do I have to do it all...
26
3167
by: Jimmy | last post by:
ill have a database with 1 table and 3 fields: ID FIRSTNAME LASTNAME (the ID field will be the auto incrementing index) there might be 10 records in the DB, there might be 10,000. i need to open the DB and randomly select a record (and then display the name, which i dont have a problem with) how can i randomly select a record? im guessing id have to open a recordset
7
7877
by: FrankEBailey | last post by:
I'm not sure if this is a completely dumb question, but please humor me :) I have a table of records, called Records, each of which has a Category_ID that places it in a specific category; the details of the categories are stored in another table called Category. What I need to do is retrieve a recordset that contains one record from each category, but where the records that are retrieved are random. I know how to retrieve one or more...
5
8161
by: muskie | last post by:
I've looked through as many posts about this as possible, but all end with no resolution. I simply need records from a table in random order, and I will be calling this recordset in a SQL statement from ASP. I've tried the following but it does not produce random order: SELECT * FROM Table1 ORDER BY Rnd(TableID) ASC; where TableID is an autonumber field. I've seen references to Randomize, but how do you use Access's
3
2201
by: Laphan | last post by:
Hi All I use a MySQL DB with my ASP classic web app. I've been asked if I can create a routine whereby I get a random number of products (records) from the DB and display these on the site. Basically every time a visitor hits the home page, they want the site to display a random selection of say 6 products. I have no problems getting the data and displaying it, my problem is
0
9786
marktang
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...
0
9641
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10769
Oralloy
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...
0
10479
jinu1996
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...
1
10523
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9312
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7741
isladogs
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...
0
5616
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...
3
3073
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.