Random Number generator for customer drawing. (1 Viewer)

iamratman

Registered User.
Local time
Today, 12:57
Joined
Feb 22, 2006
Messages
22
My company does daily, weekly, and monthly drawings using mountains of entry tickets and a barrel that has seen better days. So needless to say this system has to go. I hope to be able to do it digitally.

I would like to do a random number generator to pick the winners based off of a ticket number range. The ticket numbers issued to the customer would correspond to the customer account number. To complicate things I would really love to have the random numbers displayed on the screen so people feel they are watching the randomization pick in progress with the winner name popping up.


I have searched Help for Rnd function, as well as googled. I haven had any luck finding what I need. Is what I am looking to do possible in access? I had something similar in Excel a few years ago but lost it.
 

Smart

Registered User.
Local time
Today, 19:57
Joined
Jun 6, 2005
Messages
436
Place the following in your code

Dim ans As Long

ans = Int((99999 - 11111 + 1) * Rnd + 11111)

will produce a random number of 5 digits

99999 the highest no in the range 11111 the lowest number in the range
 
Last edited:

iamratman

Registered User.
Local time
Today, 12:57
Joined
Feb 22, 2006
Messages
22
Hello Smart,

thanxs for replying to both my posts.

I appreciate the code you donated here, I dont have anything started on this project. I'm simply not sure where to start. Need a bit of hand holding on this.: eek:

I searched high and low for a sample db I could learn from for this project but have found nothing. If any one knows where there might be something like this available it would be great.
 

john471

Registered User.
Local time
Tomorrow, 04:57
Joined
Sep 10, 2004
Messages
392
Just a thought... Could you have a "tblDraw" that you start with empty (i.e. delete all records each time before a Draw). Just have two fields.

tblDraw
-------
Chance (PK - AutoNumber - Long Integer - Random)
TicketNumber (per your needs)

When you want to do a draw, ensure you re-seed the random number generator, then INSERT INTO tblDraw all the eligible Ticket Numbers. Each one will be assigned a random (autonumber) Chance at that time. Then run a SELECT TOP 3, (or however many winning tickets you need) query sorted on the AutoNumber Chance field to determine your winning ticket(s). Create a join to the ticket table to display purcheaser details too, if you want.

SELECT TOP 3 tblTicket.TicketNumber, tblTicket.PurchasedBy
FROM tblDraw INNER JOIN tblTicket ON tblDraw.TicketNumber = tblTicket.TicketNumber
ORDER BY tblDraw.Chance;


You could then do up some fancy graphics to create the illusion of watching the real time random draw. It is just that the program would already know the actual result, while it "pretended" to draw it... I'm not sure if that is "kosher" or not..... ???

HTH

Regards

John
 

iamratman

Registered User.
Local time
Today, 12:57
Joined
Feb 22, 2006
Messages
22
Hey thanks John,


I will have to attempt to build what you are talking about and try it out.

I'll have to check on regulations for the visual real time display just being for show. That is a good question.
 

john471

Registered User.
Local time
Tomorrow, 04:57
Joined
Sep 10, 2004
Messages
392
You could probably argue the point, if the "show" happens within a reasonable amount of time of the actual determination of the result (i.e. less than a minute or so???) and no manipulation of the result is possible.... How is it that different to the barrel girl standing on stage with a microphone, pulling out a winning ticket, and saying "The winning ticket is blue... The ticket number starts with 'A'..... the winning ticket is blue ticket 'A......1.....0.....5.......4.......9' !!!!" Or something like that. Anyway, as you suggest, best to check with the relevant authorities/reulators. You could make the above comparison to strengthen your case.
 

iamratman

Registered User.
Local time
Today, 12:57
Joined
Feb 22, 2006
Messages
22
I think as long as I can demonstrate that the process is truly random then it shouldn’t matter how the display works. I will probably try to build something to demo before trying to sell it. It's easier to sell that way. But I do like your argument and will use it.

That “medium you strike” must have described our drawings because you see them so clearly... :)

You think this project would be expensive to have a coder build? Between the db and figuring out how to do the graphic display It may take some time for me to get smart enough to build this. Although it would be a good way to learn some pretty cool stuff.
 
Last edited:

john471

Registered User.
Local time
Tomorrow, 04:57
Joined
Sep 10, 2004
Messages
392
iamratman said:
You think this project would be expensive to have a coder build? Between the db and figuring out how to do the graphic display It may take some time for me to get smart enough to build this. Although it would be a good way to learn some pretty cool stuff.

Sorry, I couldn't begin to guess; I have a day job that sometimes involves work along this line, but mostly this is just stuff I do outside of work hours (even though often it is to the benefit of the compay). So I don't charge out hours or anything like that to know, really. The draw part is pretty simple, if the premise is accetable to you. You just need a button on a form to clear all entries from the draw table, re-seed the random number generator & run the insert query. The draw is done! To return the results, you need a seperate SELECT TOP query. I assume you wouldn't display the "chance" field to anyone, so it won't matter if your TOP query sorts Ascending or Descending. If you do think you need to display the Chance field, be aware that it will (more than likely) contain some negative numbers. If you sort Ascending, your winners will be the ones with the largest negative numbers, conversely if you sord Descending,your winners will be the ones with the highest (positive) Chance numbers. If you were to display the Chance number, it might be more palatable (to an uneducated audience) that the highest number wins.

To put on a "show", well by now you know what (ticket) number(s) you need to arrive at, you just need a routine that looks like it is cycling through random ticket numbers and stopping, or maybe "building" the winning ticket number, one "random" digit at a time. That would probably be easiest - you could build each digit with a frurther "actually random" routine that keeps displaying its random number until it actually hits the required one (for the first, second, third, fourth or whatever time - depends how long you want to "draw out the show" for).

HTH & good luck with your project.
 

Users who are viewing this thread

Top Bottom