Listbox last 6

David B

Board Regular
Joined
Jun 3, 2006
Messages
75
Hey guys'
I want to have a list box on a report that shows the last 6 records only. I have another report that I hope to show all records in the DB (or that meet a criteria), but its this snapshot on the top of the report that the manager just wants the last 6 events/records.

Hope someone has a way to show this.
thanks in advance David B
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
I think you can drop the first report into the seconds report header as a subreport. You can probably do this with a drag and drop in design view.

ξ
 
Upvote 0
Thank for that input. I didnt think about that step. But I am now.
But my initial req for help stands. My table has a few Yrs of data we cant trim that at all. (Data retention)
But the manager wants a report that shows the last 6 rows in the datatable. ie last 6 months for selected fields. I tried to sort Descending but sure there is a way I can tell the qry to only show me last 6 records.
Hope someone has an idea!
 
Upvote 0
If last 6 months and last 6 records are the same thing, use a Max() criterion:

Select field, field, field WHERE field >= (SELECT Max(date_field) - 200))

Though you'd probably want to use a datepart or datediff kind of formula for more precision. Or even a DateSerial with Month - 6. Offhand I'm foggy on the details (obviously). But it's your typical datehandling functions that you rely on, whichever they are.
 
Upvote 0
If you can sort descending you can use the Top predicate like this

Code:
SELECT TOP 6 MyDateField, OtherFields
FROM MyTable
ORDER BY MyDateField DESC;

Or something like that.

hth,

Rich
 
Upvote 0
Have you tried the Return drop down box in the query. If you sort the query the right way you can type in 6 in the Return and it shoudl work.
 
Upvote 0
Hey guys.
Ravans hit it on the spot. So simple. Im embarrassed I didn't think or know that.
Thank you very much. I really appreciate it.
david
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,876
Members
452,949
Latest member
Dupuhini

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top