Re: Query (last 40 recent dates) (Accesss 2000)

<P ID="edit" class=small>(Edited by patt on 26-Mar-03 15:55. Click on properties)</P>No, go into query design mode (the grid view of the query), then select the SQL mode of the query and paste what I previously said into this area.
The other way to do this is to start a new query, select your table, drag the date down to the grid. Next right click in the top grey area, click onto properties and enter 40 into the top parameter.
HTH
Pat

Re: Query (last 40 recent dates) (Accesss 2000)

Hi Pat,

>>>The other way to do this is to start a new query, select your table, drag the date down to the grid. Next right click in the top grey area, click onto properties and enter 40 into the top parameter.<<<

When I right click in the grey area a box called "query properties" opens up. The top parameter is "Description" is this where I should enter 40?

I also have a third field called "Time" (I left it out to make it easier to explain what I was trying to do). I"m not sure but if I do enter 40 how will I know if it is going to pull up the top 40 dates or the top 40 times?

When I put 40 in description I still get more than 40 records but if I put it in Top Values I then get 40 records but is it time or date?

Re: Query (last 40 recent dates) (Accesss 2000)

To get more of an appreciation look in the help for Top Predicate, some of which follows:

TOP n [PERCENT]
Returns a certain number of records that fall at the top or the bottom of a range specified by an ORDER BY clause. Suppose you want the names of the top 25 students from the class of 1994:

SELECT TOP 25 FirstName, LastName
FROM Students
WHERE GraduationYear = 1994
ORDER BY GradePointAverage DESC;

If you don't include the ORDER BY clause, the query will return an arbitrary set of 25 records from the Students table that satisfy the WHERE clause.

Re: Query (last 40 recent dates) (Accesss 2000)

Hi Pat,

Thanks for all of your help.

Here is how I got the results I was looking for. In the query design grid I right clicked on the top grey area as you suggested and selected properties. I then entered 40 in the top values box and closed the properties window.
Next I set the field DATE to sort in descending order, the query will find the top 40 of the leftmost colum that has sort selected.

Re: Query (last 40 recent dates) (Accesss 2000)

Just a quick FYI...on an interesting thread. When you go into the design view of a query, the 'Top Values' should actually be visible to you. Look for the word 'All' in your menus. It will be in a drop down box. That's the 'menu' option that sets the 'Top' statement for you. ('All sets nothing, but you can select from the list in the drop down, or just type the value into that box).

I'm embarassed to say how long I was developing stuff in Access, and never realized what that 'All' was doing up there, until a while back I learned about the Top Statement. Go figure!