Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Show last 5 records in subform in Access

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

839 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