Pulling up last 4 records

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to set up a query which pulls up data of workers based on their
name. What I cannot figure out is how to pull up the 4 most recent records.
There is a date associated with each record and I could normally just set up
a date criteria to just go back 4 weeks but the problem is is that there are
certain weeks the worker does not work and therefore is no data. Im sure
there is a way to simply just look up and display the last 4 records and I
just cant find it. Any help would be greatly appreciated. Thanks a lot!
 
Hi, Jamil.

Sort descending and use a "Top N" query. Try:

SELECT Top 4 DateWorked, LastName, FirstName
FROM tblAttendance
WHERE ((LastName = "Smith") AND (FirstName = "Joe"))
ORDER BY DateWorked DESC;

.. . . where DateWorked is the name of the field containing the criteria date
for recent records, LastName is the name of the field containing the workers'
last names, FirstName is the name of the field containing the workers' first
names, and tblAttendance is the name of the table.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
1. Sort the dates descending in your query.
2. Click in the query window. In the dialog that appears, click on
Properties. In the Properties dialog that appears next, set the Top property
to 4.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top