Solved

Show last 5 records in subform in Access

Posted on 2010-08-26
2
624 Views
Last Modified: 2012-05-10
I have 2 tables

Table 1: FWareHouse ( MainForm)
Fields:
FWarehouse

Table 2: FWHs Inbounds (Subform)
Fields:
FWarehouse
Fiscal Year
Week ID
Cases
Weight
XDock


in the subform i have a code

ON Load:
Private Sub Form_Load()
DoCmd.GoToRecord , , acNewRec
End Sub
It will go the last row of the subform for a new record to enter

****
I want to show the last 5 records for the selected FWarehouse from MainForm
were it shows the list  in subform in the order of  Fiscal Year, Week ID ( only last 5 records)
0
Comment
Question by:mercybthomas74
2 Comments
 
LVL 2

Accepted Solution

by:
bgrandjean earned 500 total points
ID: 33533189
sort the record source for the subform as descending for the two fields you are concerned with then to the properties for the query and set Top Values to 5
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 33542583
Change the recordsource of the subform to a query that looks like:

SELECT Top 5 FWarehouse, [Fiscal Year], [Week ID], Cases, Weight, XDock
FROM yourTable
WHERE [FWarehouse] = Forms!yourFormName.txtFWareHouse

Then make sure that the form and subform are not linked via a master/child relationship.
Finally, set the main forms Current event to look like:

Private Sub Form_Current

    me.SubformControlName.Form.Requery

End Sub
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now