Results 1 to 2 of 2
  1. #1
    Alaska1 is offline Advanced Beginner
    Windows Vista Access 2003
    Join Date
    Oct 2010
    Posts
    55

    Limited the number of records returned in an access query

    I am looking to run a query in Access that will limit the number of records for each criteria.

    example:

    >10 years count 300
    1-3 years count 100


    4-6 years count 200
    6-10 years count 250

    can limit the amount in one query or have to do the criteria separate?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    I think will require separate queries, then union into one dataset. Something like:

    SELECT *, "1to3" AS Category FROM Table1 WHERE DCount("*","Table1","ID<" & [ID])+1)<100 AND YearField BETWEEN 1 AND 3
    UNION SELECT *, "4to6" FROM Table1 WHERE DCount("*","Table1","ID<" & [ID])+1)<200 AND YearField BETWEEN 4 AND 6
    UNION SELECT *, "7to10" FROM Table1 WHERE DCount("*","Table1","ID<" & [ID])+1)<250 AND YearField BETWEEN 7 AND 10
    UNION SELECT *, "Over10" FROM Table1 WHERE DCount("*","Table1","ID<" & [ID])+1)<300 AND YearField>10;

    Requires a unique record identifier field - autonumber, date/time, whatever - as long as the value is unique
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 1
    Last Post: 01-24-2013, 05:50 PM
  2. Replies: 6
    Last Post: 07-25-2011, 01:54 PM
  3. Replies: 2
    Last Post: 05-26-2011, 12:15 PM
  4. Replies: 1
    Last Post: 04-12-2011, 05:19 PM
  5. Counting returned records in a query
    By johncob in forum Queries
    Replies: 0
    Last Post: 02-11-2009, 05:30 PM

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