Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2010
    Posts
    2

    program that pick a random winner


    That anyone have a tutorial or an idea how to create a small program that pick a random winne from a customer table.if the customer is picked he can't be selected another time.

    regards.

  2. #2
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    1. give all clients a unique sequenct number (client_seq) from 0 to n, n is number of clients.
    2 select the client with client_seq=int(rnd * n) and never won
    3 if no client return from 2, repeat step 2 (this happen when that client had been picked)
    4 pick this client and update the win flag

  3. #3
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    George,

    you can also use my Random Record function: http://www.ajenterprisesonline.com/A...RndRecord.html

    The query for it is:
    Code:
    SELECT * FROM TABLE WHERE [field] = RndRecord("fieldname", "tablename")

  4. #4
    051756 is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    1
    hi,
    i have the same exact case, and i used weekend00's Sollution and it worked fine.
    But if i close access and reopen it with the old data i had before updating the win flag.
    i will run through the same random selection i had in the first place..
    is there anyway i can relate the random selection to datetime??

    the link that Adam posted returned a sequencial selection..
    i'm not sure if i used it right.
    Thanks..

  5. #5
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by 051756 View Post
    the link that Adam posted returned a sequencial selection..
    i'm not sure if i used it right.
    Thanks..
    The RndRecord() line on this page: http://www.ajenterprisesonline.com/ab/_functions/ gives you instructions on how to use the function as a call from a query.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. How to pick the n-th row from a query
    By Johnny C in forum Queries
    Replies: 2
    Last Post: 07-27-2010, 05:14 AM
  2. Eliminate redundant data from Pick Box?
    By jsbdiver in forum Forms
    Replies: 5
    Last Post: 06-14-2010, 04:04 PM
  3. Random sampling
    By uscpa in forum Queries
    Replies: 4
    Last Post: 01-23-2010, 03:12 AM
  4. Replies: 0
    Last Post: 05-16-2008, 07:50 AM
  5. Replies: 2
    Last Post: 04-17-2006, 08:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums