Full Version: How do I limit a purchase order report to the last five values p
UtterAccess Discussion Forums > Microsoft® Access > Access Reports
PebbleEric
Rather than having a "Purchases in a date range" report how to I get a report or query to kick back only the last five purchases per ProductID? Some items I purchase twice a week and others only twice a year, I would like to have a report that can give me historical value for every item that will not be 100 pages long. Thanks
Jerry Dennison
Welcome to UtterAccess!

This will require a subquery using the Top 5 predicate. Are you familiar with subqueries?
PebbleEric
I used a subquery once to obtain a unitprice for items. The more I got used to the programming language I found it reduntant and replaced it with a simple expression. I should be able to remember how to do it.
Jerry Dennison
It is often easier to create and save the subquery first then add it to your new query. If you are comfortable writing a SQL Select statement yourself then you can simply include it as one of the fields in your query.
PebbleEric
So what you are saying is make a subquary for the ProductId and date, then sort the date in decending order. Apply a predicate function to the date and swap the date fields in my main query. The only thing I'm hung up on is how to create the predicate function.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.