Results 1 to 3 of 3
  1. #1
    l3111 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Mar 2011
    Location
    Manchester, UK
    Posts
    38

    Exclamation Sort Calculated Ages in to Age Groups

    Hi I've searched high and low for this answer, i've tried formula after formula but to no avail.



    I have created a query that calculates customers ages from thier DOB
    Age: DateDiff("yyyy",[DOB],Now())

    Now my problem arises as I need to report this in groups, more precisily these groups:
    18-24
    25-34
    35-44
    45-54
    55-64
    65-74
    75-84
    85-94
    95+

    There doesn't seem to be a thread on this site that explains how best to do this. I'm using my novice head to think query, but these IIF formulas are confuuuuuusing!!

    As always, all help greatly appreciated, this forum has been a life saver with my current work project

    l3111, Manchester, UK

  2. #2
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    You would be able to achieve this simply in a form creating the group with some VBA. Here is a link to how to do a Case Select Statement.

    http://www.techonthenet.com/access/f...anced/case.php

    Once you have established your grouping, then you can do an aggregate query on the groups

    Alternatively, you could create a cross tab query based upon the groups and then aggregate the query.

    Alan

  3. #3
    l3111 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Mar 2011
    Location
    Manchester, UK
    Posts
    38
    FIXED IT

    Age Group: IIf([Age]>84,"85+",IIf([Age]>74,"75-84",IIf([Age]>64,"65-74",IIf([Age]>54,"55-64",IIf([Age]>44,"45-54",IIf([Age]>34,"35-44",IIf([Age]>34,"25-34",IIf([Age]>24,"18-24")))))))) as a field


    then use this query to create a new query

    with these fields
    Age Group (field calculated from previous query) - Group By
    Age Group - Count


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

Similar Threads

  1. forceing groups to next page
    By newtoAccess in forum Reports
    Replies: 1
    Last Post: 04-25-2011, 12:11 PM
  2. DSum in Query - Adding groups
    By Huddle in forum Queries
    Replies: 1
    Last Post: 02-04-2011, 07:53 PM
  3. How to sort by three sort orders
    By captgnvr in forum Access
    Replies: 4
    Last Post: 11-09-2009, 07:30 AM
  4. Group & Reports (more than 4 Groups??)
    By JohnS in forum Reports
    Replies: 3
    Last Post: 10-01-2009, 07:11 AM
  5. using date for groups
    By antcox2004 in forum Reports
    Replies: 3
    Last Post: 01-28-2006, 07:44 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