only show last 12 records in a subform

D

Database User

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?
 
O

Ofer

Use the TOP in the select statement

Select TOP 12 PayAmount, PayDate From TableName Order by PayDate Desc
 
O

Ofer

The order by date payment desc will return the last 12 payment, changing it
to sort by asc will return the first 12 payment
 
D

Database User

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?
 
O

Ofer

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
 
D

Database User

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
 
O

Ofer

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
 
D

Database User

THank you so i just want to make sure i have this clear. I go to the query
that the subform is based on and then go to the SQL and at the begining where
it says Select i add in top 12 then right at the end i write where
MemberField (- is that refering to my Member ID field) = Forms etc and the
whole code that you wrote - is that right?

Ofer said:
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

--
I hope that helped
Good luck


Database User said:
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
 
O

Ofer

Dont forget in the Query the OrderBy desc
=====================================
And in the SQL of the Form Order by Asc

Select * From QueryName Order By DateField Asc
=====================================
So, try it, and will continue from there

--
I hope that helped
Good luck


Database User said:
THank you so i just want to make sure i have this clear. I go to the query
that the subform is based on and then go to the SQL and at the begining where
it says Select i add in top 12 then right at the end i write where
MemberField (- is that refering to my Member ID field) = Forms etc and the
whole code that you wrote - is that right?

Ofer said:
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

--
I hope that helped
Good luck


Database User said:
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

:

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

--
I hope that helped
Good luck


:

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?

:

The order by date payment desc will return the last 12 payment, changing it
to sort by asc will return the first 12 payment
--
I hope that helped
Good luck


:

will that give me the first 12 or the last 12 i need the last 12? THankks

:

Use the TOP in the select statement

Select TOP 12 PayAmount, PayDate From TableName Order by PayDate Desc


--
I hope that helped
Good luck


:

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?
 
D

Database User

I did that and it worked but i didnt know how to order it asc in the subform
SQL so i just created a filter on that query, saved it as a query and based
the subform on this new query. But then when i go to any other guy it just
gives me all the guys records where should i put the Me.SubformName.Refresh
you said something about putting it on the next button but i don't think that
would work because sometimes i click find, previous, first, last to get
another customer so where should i put it?
Thanks for all your help i think we're getting there!

Ofer said:
Dont forget in the Query the OrderBy desc
=====================================
And in the SQL of the Form Order by Asc

Select * From QueryName Order By DateField Asc
=====================================
So, try it, and will continue from there

--
I hope that helped
Good luck


Database User said:
THank you so i just want to make sure i have this clear. I go to the query
that the subform is based on and then go to the SQL and at the begining where
it says Select i add in top 12 then right at the end i write where
MemberField (- is that refering to my Member ID field) = Forms etc and the
whole code that you wrote - is that right?

Ofer said:
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

--
I hope that helped
Good luck


:

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

:

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

--
I hope that helped
Good luck


:

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?

:

The order by date payment desc will return the last 12 payment, changing it
to sort by asc will return the first 12 payment
--
I hope that helped
Good luck


:

will that give me the first 12 or the last 12 i need the last 12? THankks

:

Use the TOP in the select statement

Select TOP 12 PayAmount, PayDate From TableName Order by PayDate Desc


--
I hope that helped
Good luck


:

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?
 
O

Ofer

You should put the requery command on the On current event of the main form
Me.SubformName.Requery
--
I hope that helped
Good luck


Database User said:
I did that and it worked but i didnt know how to order it asc in the subform
SQL so i just created a filter on that query, saved it as a query and based
the subform on this new query. But then when i go to any other guy it just
gives me all the guys records where should i put the Me.SubformName.Refresh
you said something about putting it on the next button but i don't think that
would work because sometimes i click find, previous, first, last to get
another customer so where should i put it?
Thanks for all your help i think we're getting there!

Ofer said:
Dont forget in the Query the OrderBy desc
=====================================
And in the SQL of the Form Order by Asc

Select * From QueryName Order By DateField Asc
=====================================
So, try it, and will continue from there

--
I hope that helped
Good luck


Database User said:
THank you so i just want to make sure i have this clear. I go to the query
that the subform is based on and then go to the SQL and at the begining where
it says Select i add in top 12 then right at the end i write where
MemberField (- is that refering to my Member ID field) = Forms etc and the
whole code that you wrote - is that right?

:

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

--
I hope that helped
Good luck


:

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

:

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

--
I hope that helped
Good luck


:

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?

:

The order by date payment desc will return the last 12 payment, changing it
to sort by asc will return the first 12 payment
--
I hope that helped
Good luck


:

will that give me the first 12 or the last 12 i need the last 12? THankks

:

Use the TOP in the select statement

Select TOP 12 PayAmount, PayDate From TableName Order by PayDate Desc


--
I hope that helped
Good luck


:

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?
 
D

Database User

Thanks so much that did it!!!

Ofer said:
You should put the requery command on the On current event of the main form
Me.SubformName.Requery
--
I hope that helped
Good luck


Database User said:
I did that and it worked but i didnt know how to order it asc in the subform
SQL so i just created a filter on that query, saved it as a query and based
the subform on this new query. But then when i go to any other guy it just
gives me all the guys records where should i put the Me.SubformName.Refresh
you said something about putting it on the next button but i don't think that
would work because sometimes i click find, previous, first, last to get
another customer so where should i put it?
Thanks for all your help i think we're getting there!

Ofer said:
Dont forget in the Query the OrderBy desc
=====================================
And in the SQL of the Form Order by Asc

Select * From QueryName Order By DateField Asc
=====================================
So, try it, and will continue from there

--
I hope that helped
Good luck


:

THank you so i just want to make sure i have this clear. I go to the query
that the subform is based on and then go to the SQL and at the begining where
it says Select i add in top 12 then right at the end i write where
MemberField (- is that refering to my Member ID field) = Forms etc and the
whole code that you wrote - is that right?

:

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

--
I hope that helped
Good luck


:

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

:

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

--
I hope that helped
Good luck


:

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?

:

The order by date payment desc will return the last 12 payment, changing it
to sort by asc will return the first 12 payment
--
I hope that helped
Good luck


:

will that give me the first 12 or the last 12 i need the last 12? THankks

:

Use the TOP in the select statement

Select TOP 12 PayAmount, PayDate From TableName Order by PayDate Desc


--
I hope that helped
Good luck


:

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?
 

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

Top