only show last 12 records in a subform

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

Guest

I have a database for a fitness club. I made a form with the member details
and then a subform with record of their monthly payments, annual payments
depending on their payment method. But i dont need to be able to see
thousands of records i only want to see the most recent 12 records? How can
this be done?
 
Use the TOP in the select statement

Select TOP 12 PayAmount, PayDate From TableName Order by PayDate Desc
 
The order by date payment desc will return the last 12 payment, changing it
to sort by asc will return the first 12 payment
 
Thank you. I'm not sure if it's going to work because i do want the last 12
records but i want them in ascending order of date. so after i've done the
selection in a query do i make a filter on that query and sort it the way i
want and then base the subform on the filter query?
 
In that case create a query as I explained above, and then create a second
query based on the first query, and order the date asc
 
So that did it but there's a problem so it gave me only the first guy in the
form, his last 12 records and then in a new query i resorted it by date, but
i want every member id to have in his subform the last 12 records so what
code shoud i put in the query or maybe somewhere in the subform Visual Basics
Please help
 
Create a link in the query to the field in the form

Select TOP 12 PayAmount, PayDate From TableName Where MemberField =
Forms![FormName]![MemberFieldName] Order by PayDate Desc

When you move to the next member, run the code
Me.SubFromName.Requery
 
Back
Top