473,320 Members | 1,988 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,320 software developers and data experts.

How to generate a random number for lucky draw from a query

547 512MB
At every cycling race, there is a lucky draw afterwards based on the cyclist racenumber for that race.(race numbers may change from race to race per person)

I need to create a lucky number generator on a form, where you press a button, and a race number is selected randomly from this current race, and appears on the screen.
My table is called "RaceEntry" and the racenumber field (used in lucky draw) is called "RaceNo".
I will probably have to use a query to filter this table based on a "racedate" in order to get only lucky numbers from a specific race.
The numbers are usually from 1 to 1500 but may vary from race to race.

Any suggestions?
May 10 '11 #1
2 3151
Rabbit
12,516 Expert Mod 8TB
You could use the Rnd function and seed it with the time in milliseconds times the racenumber. Then you can select the top 1 from the result.
May 10 '11 #2
NeoPa
32,556 Expert Mod 16PB
Whenever you need to select an item randomly, and especially when the selected items are other than a simple sequential list, you need the items to select from to be stored in a container of some form (A table, or even a query, is fine for this in Access) and then you find a random number between 0 and the last numbered item in the container. Rnd() returns a value from 0 and up to, but not including, 1. If this result is multiplied by the number of items in the container and a half added (to avoid reduced weighting for the end values 0 and Max) and rounded to the nearest whole number up, you will have the number of items (records) to move to select the specified item.
May 11 '11 #3

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

Similar topics

2
by: vishal | last post by:
hi i want to generate a string which contains 5 characters and all 5 characters are randomly generated means it is not fixed that which string i will get after i execute function. so tell me...
3
by: vishal | last post by:
i want to generate a random number of a fixed length so how can i do this ?? i know some function which returns a single random character at a time but is there any built-in function which...
12
by: Sweety | last post by:
plz reply, thanks in advance. bye
4
by: fatimahtaher | last post by:
Hi, I am supposed to create a program that generates a random number and then asks the user to guess the number (1-100). The program tells the user if he guessed too high or too low. If he...
19
by: Sanchit | last post by:
I want to generate a randowm number between two numbers x and y i.e int randomNoBetween(int x, int y); Plz help Is there any such function??
2
by: Man4ish | last post by:
How to generate random number in normal distribution without using any external library. I found few methods implementing it. But all use GSL or boost. I don't want to use any third party library....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.