A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Selecting the last 10 records from a specific date



 
 
Thread Tools Display Modes
  #1  
Old June 3rd, 2010, 05:30 AM posted to microsoft.public.access.gettingstarted
semmison
external usenet poster
 
Posts: 1
Default Selecting the last 10 records from a specific date

I have a date field and name field, I want to return the last 10 Name records
entered from a specific date..... ie: Count back 10 records in the date field
from Todays date and display the names from that date, to today.... seems
really simple but I can't get it right...
Ads
  #2  
Old June 3rd, 2010, 07:14 AM posted to microsoft.public.access.gettingstarted
xps35
external usenet poster
 
Posts: 22
Default Selecting the last 10 records from a specific date

=?Utf-8?B?c2VtbWlzb24=?= wrote:


I have a date field and name field, I want to return the last 10 Name records
entered from a specific date..... ie: Count back 10 records in the date field
from Todays date and display the names from that date, to today.... seems
really simple but I can't get it right...


You can use TOP in an query. Something like:

SELECT TOP 10 FROM ...... ORDER BY SomeField DESC


But.....

You must be able to sort the entries by a field that tells the order of
entry.

--
Groeten,

Peter
http://access.xps350.com

  #3  
Old June 3rd, 2010, 01:02 PM posted to microsoft.public.access.gettingstarted
John Spencer
external usenet poster
 
Posts: 7,815
Default Selecting the last 10 records from a specific date

A query that would look something like the following.

SELECT TOP 10 NameField, DateField
FROM SomeTable
WHERE DateField = Date()
ORDER BY DateField DESC

In query design view
== Add the table
== Add the two fields
== Under the DateField enter criteria
= Date()
== Set the datefield to sort DESCending
== In the query properties, set Top Values to 10

This will return ties for the last position.

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

semmison wrote:
I have a date field and name field, I want to return the last 10 Name records
entered from a specific date..... ie: Count back 10 records in the date field
from Todays date and display the names from that date, to today.... seems
really simple but I can't get it right...

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:22 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright 2004-2017 OfficeFrustration.
The comments are property of their posters.