Solved

Access 2007 - getting every nth record from a query

Posted on 2009-03-30
2
480 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 - Access MVP) earned 125 total points
Comment Utility
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 - Access MVP)
DatabaseMX (Joe Anderson - Access MVP) earned 125 total points
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now