473,408 Members | 2,813 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,408 software developers and data experts.

random selection

am having a problem of selecting 40 rows at random from a table every single time this is my code:

Expand|Select|Wrap|Line Numbers
  1. Set oRs = oDatabase.Execute("SELECT Top 40 * FROM Questions ORDER BY Rnd(QID)", , adOpenForwardOnly Or adLockReadOnly) 
and i also try this code not working for me: Here is the syntax (x = table, ID = field)


Expand|Select|Wrap|Line Numbers
  1. SELECT TOP 1 x.ID
  2. FROM x
  3. ORDER BY Rnd([id])*[id]*Now();
Pls Help me.....
Jun 22 '12 #1
5 2257
Mihail
759 512MB
Expand|Select|Wrap|Line Numbers
  1. SELECT TOP n X.*
  2. FROM X
  3. ORDER BY Rnd([ID])*[ID]*Now();
where "n" is the number of records ( =1 or =40 )
Jun 23 '12 #2
Thanx Mihail for you concern i tried this code:

Expand|Select|Wrap|Line Numbers
  1. Randomize
  2.   Set oRs = oDatabase.Execute("select top 40 Questions.* from Questions order by rnd([QID])*[QID]*Now()")
where Questions =table

My problem is the same set of question row is been selected at random at every run time
Jun 25 '12 #3
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code.

Your parentheses is in the wrong place.
Expand|Select|Wrap|Line Numbers
  1. select top 40 Questions.* 
  2. from Questions 
  3. order by rnd([QID]*[QID]*Now())
Jun 25 '12 #4
thanx Rabbit but the code is not randomizing
different row at every run time....
Expand|Select|Wrap|Line Numbers
  1. Randomize
  2. Set oRs = oDatabase.Execute
  3. ("select top 40 Questions.* from Questions
  4.  order by Rnd([QID])*[QID]*Now()")
and i also try this:
Expand|Select|Wrap|Line Numbers
  1. Randomize
  2.   Set oRs = oDatabase.Execute
  3. ("select top 40 Questions.* from Questions
  4.  order by Rnd([QID]*[QID]*Now())")
Jun 27 '12 #5
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code. This is your second warning.

First of all, your code can't possibly run. Execute is for action queries and what you have is not an action query. So when you say that it's not randomizing, I have no idea how you can even say that if the code won't even run.
Jun 27 '12 #6

Sign in to post your reply or Sign up for a free account.

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: Andie | last post by:
Hello All, How would I go about using a disconnect recordset and select (x) records from it, x being the number of records to be selected. Many thanks in advance. -- Andie
3
by: Gunnar | last post by:
Hello. Problem: How can I select K random values from the elements 0,1,2,3,4...,N-1 ? I don't know if there's an easy way of doing this, but here are suggestions for doing it. One way is...
1
by: Micak | last post by:
I'm using radnom selection in ms access to select certain number of questions for the exam. i have two versions of the report: - one without marked answers - one with marked answers the problem...
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...
2
by: Tartifola | last post by:
Hi, I have a list with probabilities as elements with of course p1+p2+p3=1. I'd like to draw a random element from this list, based on the probabilities contained in the list itself, and...
13
by: Bruza | last post by:
I need to implement a "random selection" algorithm which takes a list of as input. Each of the (obj, prob) represents how likely an object, "obj", should be selected based on its probability of...
3
by: Manuel Ebert | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Dear list, who's got aesthetic advice for the following problem? I've got some joint probabilities of two distinct events Pr(X=x, Y=y), stored...
5
by: DruidWanderer | last post by:
I'm attempting to create a frame that loads a page with a specific variable based on a random number, but I can't seem to get it to work. Any help would be greatly appreciated. Here's what I've got...
0
by: sentimental37 | last post by:
Hello everybody, I am developing a c# application in which i am using access2007 database. I want to select random records from the database through an access query in c#.but i am...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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...
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...

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.