473,890 Members | 1,339 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Random Question generator for MS Access

1 New Member
I am use the MS Access Form as frontend and ms-access Database as backend
I want to retrive 10 question randomly from database out of 100 question
simultenously in richtextbox. If i click on next button then second question display.
I am use the four radio button for option
and I click on finish button then show the result and how iam store the 10 question with user answer in database.
Nov 24 '12
14 9420
ADezii
8,834 Recognized Expert Expert
My approach is similar to zmbd's in that I always use the Recordset approach for generating x number of Random Records for a Data Set of y Records. The general Logic is as follows (using 10 Random Records out of 100):
  1. Generate 10 Random Numbers between 1 and 100, storing each in an Array.
  2. Loop thru the Array checking for Duplicate Values.
  3. Should there be Duplicate Value(s), generate another Random for that Slot.
  4. Repeat this process until all 10 Randoms are now Unique.
  5. We now have 10, Unique, Random Numbers stored in an Array which now act as Record Pointers to the 100 Record Data Set.
  6. Now we can use some mechanism to Navigate to each Record position defined by the Array, and retrieve the appropriate Values.
Nov 26 '12 #11
zmbd
5,501 Recognized Expert Moderator Expert
I'm afraid I cheat even further than that... I use a class module and use the primary key as the name of the instance. I got the idea from reading thru an example where students and rooms were being handled. At the time it really didn't make much sense when tables would do the job - but then I had a need for the quiz... I was playing with Class modules... already had the jack-hammer out of the toolshed.

The other way I've done this is using a listbox on a form (oh yes, I went there) and then do the loop thingy to check for duplicates much like an array.

In either method... I still open a record set in VBA and pull the random records.
Nov 26 '12 #12
NeoPa
32,584 Recognized Expert Moderator MVP
What I do is to create an array of integers that reflect all the record numbers (or record offsets) that exist in the dataset. Each element of the array is initially populated with a number matching its own position (IE. Element[0]=0; element[1]=1; element[2]=2; etc). N is set as the number of records.

Now, for each iteration through the loop, a random number (R) is generated such that 0 <= R < 1. R is multiplied by N and the integer portion taken (NOT rounded but truncated.), giving a random integer (X) between 0 and 9 on the first iteration through the loop. Importantly, element[N] is then swapped with element[X]. Lastly, X is decremented (X = X - 1). The last two steps ensure that only unselected values are available for selection next time through the loop.
Nov 26 '12 #13
zmbd
5,501 Recognized Expert Moderator Expert
That's slick... I've done somthing like that with two list boxes... moved the element from one to the second... just for user touchy-feely :-)
Nov 26 '12 #14
NeoPa
32,584 Recognized Expert Moderator MVP
Thanks Z. I originally came up with this approach when looking for a way to shuffle cards before dealing (hence the swapping of the elements rather than the simpler moving of [N] to [X]). I struggled to come up with something that would work and not be clumsy, but I only came up with this as a fully formed solution after waking up one day.
Nov 26 '12 #15

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

Similar topics

6
2404
by: Trythat | last post by:
This might seem a stupid question but here goes - I wrote a key generator for one of my programs in Visual Basic, so I recieve sales notification via email and then use my program to generate the key and send it via Email. Well after finding out about PHP, and that my host does PHP, I thought it would be quicker and more reliable to generate the keys on the server and send them out again either vai email or from the sales site.
21
3044
by: Marc Dansereau | last post by:
Hi all I am new to this forum and to the c programming language. If I understand, the random() function in C return numbers that follow a uniform distribution U(0,1). Can somebody know how to generate a set of random number that follow a normal distribution N(0,1) ? I am develloping on power4 machine running AIX. Thank you for your help
16
7198
by: Claudio Grondi | last post by:
I have a 250 Gbyte file (occupies the whole hard drive space) and want to change only eight bytes in this file at a given offset of appr. 200 Gbyte (all other data in that file should remain unchanged). How can I do that in Python? Claudio Grondi
14
3513
by: kittikun | last post by:
Hi all, I was wondering if there is a random generator that is "reversible". I need to go back in time in my application and still need to use deterministic random numbers. Most of RNG implement the Next function but what about a Prev ? I know I can use an array to store X last values but I'm more interested to know if it exist something that allows to go backwards. Also I can't really afford to use the same seed and loop until i get
3
2985
by: adonis | last post by:
hello. i need some help with a c or c++ program. a program for generating random numbers with exponential and poisson distribution. please sombody help. thanks.
11
3028
TTCEric
by: TTCEric | last post by:
This will be original. I promise. I cannot get the random number generator to work. I tried seeding with Date.Now.Milliseconds, it still results in the same values. What I have are arrays of values. I get a random index value for each array so I can pull the data from them.
4
9408
by: Ruhi22 | last post by:
I am trying to use the default random generator in C. the funcion rand() is fine but when tried 'srand(time(0))' it is giving me the following error: error C3861: 'time': identifier not found the code I am tryin it in is as follows:
0
9980
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
9826
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
11236
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
10830
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
10925
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,...
1
8018
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
6061
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4682
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
3
3283
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.