Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9023385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:44:55+00:00 2026-06-16T05:44:55+00:00

I am using Windows 7, Access 2010 I have a database that I need

  • 0

I am using Windows 7, Access 2010

I have a database that I need to return a random set of records from. The tables are relational.

I have the following tables:

  • Competencies
  • Elements
  • Sections
  • Examples

I created a query with an expression that numbered the records and I was able to randomly select x number of records.

The issue is:
Within the Elements, I need to RANDOMLY select x number of Sections within EACH element. So with my current set up I get x number of sections but it does not include at least one section from each Element. I would like to return say 25% of sections from each element.

i.e.
Element: 7.1, 7.2, 7.3, 7.4
Section: 7.1.1, 7.1.2, 7.1.3: 7.2.1, 7.2.2, 7.3.3 etc

My query is returning randomly but not from EACH element. So I might have all from element 7.1, 1 from 7.2 and nothing from 7.3 or 7.4.

Is there a way to do this? I think I might need a loop but I am completely unfamiliar with that so I’d need help with the appropriate VBA code to get it to work.

I have googled everything I can think of and I’m not getting anywhere.

Any help would be greatly appreciated!

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T05:44:58+00:00Added an answer on June 16, 2026 at 5:44 am

    You should be able to use a “select n from group” type of query, but you will need a unique ID:

    SELECT
      t.ID, 
      t.Element, 
      t.Section
    FROM Elements AS t
    WHERE t.ID In (
         SELECT Top 2 ID 
         FROM Elements q 
         WHERE q.Element=t.Element 
         ORDER BY Rnd([id])*1000)
    

    I have been over this a number of times and I reckon you are going to have to add a field for your random sort, then update the field before you run the query. This will update a field called RandomNumber in [Competency Elements]

     UPDATE [Competency Elements] 
     SET [Competency Elements].RandomNumber = Rnd([element id])*1000;
    

    Then the percentage select, I think it has to be greater than 33 for this particular data set:

    SELECT Val([comp section number]) AS [Sect No],
           s.[section description],
           e.[element number],
           e.[element description],
           Rnd(e.[element id])        AS Expr1,
           s.[section id],
           e.[element id],
           x.example,
           s.[competency id],
           c.[comp number],
           c.[competency category]
    FROM   competencies AS c
           INNER JOIN (([competency sections] AS s
                        INNER JOIN [competency elements] AS e
                                ON s.[section id] = e.[section id])
                       INNER JOIN examples AS x
                               ON e.[element id] = x.[element id])
                   ON c.[competency id] = s.[competency id]
    WHERE  (( ( e.[element id] ) IN (SELECT TOP 35 PERCENT [element id]
                                     FROM   [competency elements] q
                                     WHERE  q.[section id] = e.[section id]
                                     ORDER  BY randomnumber) ))
    ORDER  BY Val([comp section number]); 
    

    There are a number of issues around getting a random selection from a group.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Microsoft Access 2010 database(*). Now, using Visual Studio 2010, I want
I have an ASP.Net application where I am using Windows authentication to deny access
How to connect to a Microsoft Access-based database in a Windows using JDBC code?
I need to access to a shared resource with a windows service using local
I'm using MSYS in Windows. I need to access a file in MSYS home
Using windows server, I have a path to a file that, when you click
First off, I'm using Access 2000 and DAO. I have code that executes a
I am using Visual Studio 2010, Windows 7 and IIS. I have written a
I want to access certain form elements from classes that normally don't have access
We have enabled web access to our TFS 2010 server. We have a set

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.