Results 1 to 3 of 3
  1. #1
    shod90 is offline Competent Performer
    Windows 8 Access 2016
    Join Date
    Jan 2016
    Posts
    134

    Select top N records

    Dear Gents,
    Is there a way to let the user when he opens the report to choose top N records he wants , As an example i need him to choose the most purchased items in his store from date till date and there is a text box to enter how many records he want to see .


    Is it possible ?

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    use the TOP element of a query

    SELECT TOP 10 * FROM myTable

    You will need to use VBA to build the sql string because you cannot use the 10 like a criteria. e.g.

    So say you user has entered 20 in a text control called txtRecordsRequired

    in the after update event of that control put

    me.recordsource="SELECT TOP " & txtRecordsRequired & " * FROM myTable"

  3. #3
    shod90 is offline Competent Performer
    Windows 8 Access 2016
    Join Date
    Jan 2016
    Posts
    134
    Silly me , The answer was very easy lol .. Thanks it works.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. using combo box to select records
    By snorbs in forum Programming
    Replies: 4
    Last Post: 05-19-2017, 07:53 AM
  2. Replies: 6
    Last Post: 09-07-2014, 11:29 AM
  3. select particular records only
    By johnbest in forum Queries
    Replies: 1
    Last Post: 12-06-2013, 02:03 AM
  4. Replies: 2
    Last Post: 05-28-2013, 04:00 PM
  5. select records in recordset
    By sksriharsha in forum Programming
    Replies: 3
    Last Post: 09-05-2009, 11:40 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums