Solved

Show last 5 records in subform in Access

Posted on 2010-08-26
2
613 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
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…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

707 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

12 Experts available now in Live!

Get 1:1 Help Now