limiting number of records in form

S

stujol

using access 2007, i have my main form with command buttons on. the command
button click event is =EquipmentHistory("P2602A")

Public Function EquipmentHistory(equipment As String)

DoCmd.OpenForm "frm_ShiftLog_PlantLog_PlantChanges", , , "SourceField =
'" & equipment & "'", acFormPropertySettings, acDialog

End Function

when the command button is clicked, a new form is open as a continous form
showing all records for the sourcefield. my problem is some times when the
form is opened, it displays many records. i want to limit my records
displayed in the continuous form to the top 10.

the from is based on a qry,

SELECT qry_Plant_Changes.EditDate, qry_Plant_Changes.BeforeValue,
qry_Plant_Changes.AfterValue, qry_Plant_Changes.SourceField
FROM qry_Plant_Changes
ORDER BY qry_Plant_Changes.EditDate DESC;
 
A

Arvin Meyer [MVP]

Use the TOP predicate in your query:

SELECT TOP 10 qry_Plant_Changes.EditDate,
qry_Plant_Changes.BeforeValue,
qry_Plant_Changes.AfterValue,
qry_Plant_Changes.SourceField
FROM qry_Plant_Changes
ORDER BY qry_Plant_Changes.EditDate DESC;

If there are ties in values, you may get more than 10 records.
 

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