Results 1 to 6 of 6
  1. #1
    rwahdan1978 is offline Advanced Beginner
    Windows 11 Access 2016
    Join Date
    Jun 2024
    Posts
    57

    put random row of data (from query) to form

    Hi,

    I have a query that will choose a random record (1 record) and now I want to put that record into a form controls, how to do that?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Did you try binding form to query?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    rwahdan1978 is offline Advanced Beginner
    Windows 11 Access 2016
    Join Date
    Jun 2024
    Posts
    57
    Quote Originally Posted by June7 View Post
    Did you try binding form to query?
    Yes but I am always getting the same order say records (42, 10,11,etc...) no matter how many I re-run the app? It should be different everytime?

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,568
    If the query is choosing one record, how are you getting multiple records in the form?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,939
    Better show your query that generates the random record - sounds to me you are not seeding it

    have you seen this link as to how to use the rnd function (I assume that is what you are using)

    https://learn.microsoft.com/en-us/of...p/rnd-function

  6. #6
    Join Date
    Jun 2022
    Posts
    28
    Here's a query that returns a single random row using a unique numeric field (preferably an auto-numbered ID if you have one).

    Code:
    SELECT TOP 1 * FROM table ORDER BY RND(table.id)

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

Similar Threads

  1. Replies: 10
    Last Post: 04-04-2022, 05:33 PM
  2. Replies: 19
    Last Post: 04-09-2018, 05:56 PM
  3. Replies: 2
    Last Post: 05-29-2015, 11:16 AM
  4. Replies: 2
    Last Post: 03-05-2015, 01:43 PM
  5. Random Loss of Data
    By jbstearns in forum Access
    Replies: 14
    Last Post: 01-26-2015, 02:40 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