Results 1 to 11 of 11
  1. #1
    drew2020 is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2020
    Posts
    11

    Result in a Textbox Help

    Hi,



    I am creating an electronic raffle that randomly pulls a record from the table. I create a query Rnd([tblUserProfile]![ID]) and created a form from that query.

    How to put the result on the Result Textbox when I click the stop button? and the names on the Result Textbox will not be included on the next draw?
    Click image for larger version. 

Name:	raffle.PNG 
Views:	29 
Size:	14.8 KB 
ID:	43094


  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,527
    Code:
    IRnd=RND(...)
    bFound=dlookup("[id]","tPicked", "[id]=" & iRnd)
    while bFound
       IRnd=RND(..)
       bFound=dlookup("[id]","tPicked", "[id]=" & iRnd)
    wend
    
    TxtBox = dlookup("[name]","tPeople", "[id]=" & iRnd)
    Save the id in a table so you don't repeat it.

  3. #3
    drew2020 is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2020
    Posts
    11
    Hi, Where should I put those code. I apologize I am a newbie. Thank you so much.

    Click image for larger version. 

Name:	code.PNG 
Views:	24 
Size:	18.3 KB 
ID:	43095

  4. #4
    drew2020 is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2020
    Posts
    11
    "Save the id in a table so you don't repeat it."Should I make a new table for list of winner?

  5. #5
    drew2020 is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2020
    Posts
    11
    Is it okay if you edit my code? see attach file. . I appreciate it.
    Attached Files Attached Files

  6. #6
    drew2020 is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2020
    Posts
    11
    Quote Originally Posted by ranman256 View Post
    Code:
    IRnd=RND(...)
    bFound=dlookup("[id]","tPicked", "[id]=" & iRnd)
    while bFound
       IRnd=RND(..)
       bFound=dlookup("[id]","tPicked", "[id]=" & iRnd)
    wend
    
    TxtBox = dlookup("[name]","tPeople", "[id]=" & iRnd)
    Save the id in a table so you don't repeat it.
    Where should I put these code. I am a newbie and starting to learn ms access. I really appreciate your help.
    Attached Files Attached Files

  7. #7
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,421
    See if this will work for you.
    Added a true/false field to the table named Drawn.
    If a name is chosen, Drawn is set to true.
    Added criteria to the form recordsource query to not select records with Drawn=True
    Added a button to the form to reset all rows to Drawn=False (if needed).

    eRAFFLE-davegri-v01.zip

  8. #8
    drew2020 is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2020
    Posts
    11
    Quote Originally Posted by davegri View Post
    See if this will work for you.
    Added a true/false field to the table named Drawn.
    If a name is chosen, Drawn is set to true.
    Added criteria to the form recordsource query to not select records with Drawn=True
    Added a button to the form to reset all rows to Drawn=False (if needed).

    eRAFFLE-davegri-v01.zip

    Thank you for this one. I appreciate your help but I am loooking for a different way. Is it possible to do requery if error occurs? I am planning to append the ID result from drawn to another table and make the ID the primary key so that when draw result to a ticket that already pick before it will be an error , then I want to it to requery to another pull another ticket. is that possible?

  9. #9
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,421
    Click image for larger version. 

Name:	list.png 
Views:	15 
Size:	12.1 KB 
ID:	43102

    Changed the result textbox to a listbox.
    Added table tblDrawn. It holds the ID of the chosen users and the date/time chosen.

    eRAFFLE-davegri-v02.zip
    Last edited by davegri; 10-03-2020 at 04:51 PM. Reason: added image

  10. #10
    drew2020 is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2020
    Posts
    11
    Quote Originally Posted by davegri View Post
    Click image for larger version. 

Name:	list.png 
Views:	15 
Size:	12.1 KB 
ID:	43102

    Changed the result textbox to a listbox.
    Added table tblDrawn. It holds the ID of the chosen users and the date/time chosen.

    eRAFFLE-davegri-v02.zip
    That is exactly the result I want. Thank you so much. Godbless You.

  11. #11
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,421
    Glad to help. Good luck with the project.

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

Similar Threads

  1. Replies: 2
    Last Post: 12-22-2015, 09:09 PM
  2. Displaying Query Result in a textbox
    By amc1902 in forum Queries
    Replies: 8
    Last Post: 10-17-2014, 04:22 PM
  3. Replies: 9
    Last Post: 05-02-2014, 11:09 AM
  4. Enter query result in a form textbox
    By Damo10 in forum Forms
    Replies: 2
    Last Post: 06-30-2013, 06:43 PM

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