Solved

Access 2007 - getting every nth record from a query

Posted on 2009-03-30
2
488 Views
Last Modified: 2012-05-06
I have a query with many conditions that returns 332 records (at this time.)  I can use DCOUNT to count the number of records and then I divide that by 15, and the rounded number I get is 22.  I now want to only show (or extract to another query) every 22nd record.  I am having trouble with this seemingly easy part.

If I could get a field in the query that was simply the record #, I could then take only the records where the record # /22 is an integer.  There are other ways as well, I'm sure.  Maybe lack of sleep is preventin me from seeing this.  Help would be greatly appreciated.
0
Comment
Question by:pmpatane
  • 2
2 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 125 total points
ID: 24024315
Well ... IF ... you added the Auto Number to the underlying table AND if ... it can remain sequential with no gaps - then you could use the Mod function on that as a criteria to only display

[YourAutoNumberFieldName] Mod 22 = 0

mx
0
 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 125 total points
ID: 24024330
Here is a generic example:

SELECT tblEmp.*
FROM tblEmp
WHERE ((([EmpID] Mod 22=0)=True));

Again however ... this would depend on your auto number remain sequential ... which may not be practical in your case ?

mx
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question