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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Limiting Records in a Query

Status
Not open for further replies.

3rdRail

Programmer
May 26, 2000
15
CA
Is there anyway to limit the number of records a query returns to 5 in a local table<br><br>The Access help says that the MAX RECORDS property is only for an ODBC source.&nbsp;&nbsp;I'm using a local mdb and trying to return the TOP 5 records.&nbsp;&nbsp;The problem:&nbsp;&nbsp;If there is a tie ie 5,4,3,2,2,2,2.&nbsp;&nbsp;The query is returning all 7 records.&nbsp;&nbsp;What I would like it to do is return ONLY 5 and base the last one on some other criteria.<br><br>Thanks in advance for any and all help.<br><br>3rdRail
 
I'm sorry I can't be more technical on this, but off the top of my head I can't tell you exactly how it would be written.&nbsp;&nbsp;What I'm thinking though is, why not select all records as a recordset then set up a while loop to five.&nbsp;&nbsp;Inside the loop you can do a rst.movenext(think that's what it is) to the next record in the recordset.&nbsp;&nbsp;This should only return five records, instead of the seven you keep getting.&nbsp;&nbsp;I hope this approach works for you or at least gives you some ideas on where you can go from here. Good luck!&nbsp;&nbsp;<br><br>xtreme_<br><A HREF="mailto:rbio@excite.com">rbio@excite.com</A>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top