How do I retrieve the previous and next rows in an Access database usng a query?

Posted on 2008-06-23
Medium Priority
Last Modified: 2013-11-28
I have a database that lists a large amount of production jobs for the my company.  I order the rows by job number, but I was wondering how to accomplish this task with a query so I could end up putting all this information on a report.

What I want to do is grab the previous and next row's job number of the row that is currently populating the report.

For example, if I am looking at the report for job number 5, I want to put fields on the report that would list the previous and next job number in the database (maybe 4 and 6).  This is so the user knows where the jobs was and where it is headed.

What would be the best route to accomplish this task?

Question by:zrancidr
LVL 120

Accepted Solution

Rey Obrero (Capricorn1) earned 2000 total points
ID: 21849640
see this link for several ways


Author Closing Comment

ID: 31469911
Looks like that has everything I could want.  Thanks for the quick answer!

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
If you need to implement application level security in an Access database application or other VBA code, I strongly encourage you to take advantage of Active Directory groups.
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

607 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