Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

limit recordset to a form

Status
Not open for further replies.

shelspa

Technical User
Dec 13, 2001
66
US
I have a data entry form based on a table. I want it to open for only the top (or most recent) 75 or so records based on the autonumber field or date field for greater speed. I don't need all my 12,000 or so records available here. I want this done automatically when the form is opened. Ideas?
 
If you are concerned with performance, you will need to make the field (autonumber or date) an index.

Then, you can make your form's records source an sql queyr such as:

SELECT TOP 5 * FROM TheTable ORDER BY AutonumberFieldName

You could also do something like this:

Select * from TheTable where ModifiedDate >= Today - 7

for information modified in the last week.

of course, you would want to add a modified date field to your recordset, make it an index.

To set the modified date, use the form's BeforeUpdate property, add an invisible control to contain the modified date, and assign 'now' to the control, e.g.

private sub Form_BeforeUpdate
me.ModifiedDate = now
end sub

HTH

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top