473,434 Members | 1,638 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,434 software developers and data experts.

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 2826
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.com.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
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...
3
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...
22
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
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...
2
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...
4
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...
26
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...
7
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...
5
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...
3
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. ...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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...
1
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
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...
0
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...
0
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...

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.