Results 1 to 5 of 5
  1. #1

    Get range of records from Access DB?

    My DB has too many records and I want to break them across several pages. I know how to do it all except how to return only a specific range of records, for example if I wanted record 100 to 200, how would I do this?

    This is the code I now use to get all records:


    So how would I change this to get only items 100 to 200?

    This is access so LIMIT and OFFSET don't work.


  2. #2
    Join Date
    Apr 2009
    Pittsburgh, Pennsylvania

    This is something you will need to use Visual Basic for. There are a lot of resources online to achieve this. If you get some code and post it and need help with debugging it, I'd be glad to assist you.

  3. #3
    I'm not sure I understand why you say I need Visual Basic for this, this is code for an ASP website, or did you mean VB Code? In any case my query is in SQL.

    As I said my query is:

    I saw an example online:

    select top 5 * from
    select top 10 *
    from tblContact
    order by LastName asc) dt
    order by LastName desc

    I tried to adapt it to my code but am getting errors for now:

    Query = "SELECT TOP " & ((CurrentPage * 100) - 100) & " * FROM (SELECT TOP " & (CurrentPage * 100) & " * FROM MyItems ORDER BY EndTime ASC) ORDER BY EndTime DESC"

    The error is:

    Microsoft JET Database Engine error '80040e14'

    The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect.

  4. #4
    Join Date
    Apr 2009
    Pittsburgh, Pennsylvania
    Lets give this a try:

    SELECT * FROM MyItems AS a WHERE (SELECT count(*) FROM MyItems AS b WHERE <= between 100 AND 200
    This would assume "id" is the primary key as well, auto increment integer. Let me know if this helps you..

  5. #5
    I have some deleted records so by using the ID some pages would have less results. I would prefer with the nested/reversed TOP queries but I get an error as I posted above.

Similar Threads

  1. Replies: 5
    Last Post: 12-20-2010, 05:00 PM
  2. Expanded range - Buying shared hosts in the $50k-$800k range
    By marksy in forum Other Web Hosting Related Offers
    Replies: 3
    Last Post: 06-20-2010, 06:37 AM
  3. ban ip range but allow 1 ip in that range? how?
    By sross in forum Hosting Security and Technology
    Replies: 6
    Last Post: 03-11-2006, 07:54 AM
  4. Returning User Only Records with MsSql or Access
    By bthurman in forum Programming Discussion
    Replies: 2
    Last Post: 03-03-2006, 12:29 AM
  5. a records/cname records/mx records...
    By jmweb in forum Hosting Security and Technology
    Replies: 6
    Last Post: 02-25-2003, 01:49 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