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.
You should be able to use a “select n from group” type of query, but you will need a unique ID:
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]
Then the percentage select, I think it has to be greater than 33 for this particular data set:
There are a number of issues around getting a random selection from a group.