Results 1 to 2 of 2
  1. #1
    xnixiel is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    1

    Grouping By Age

    Hey guys, I've got a query groups people into age groups using a module and query. This works absolutely fine except I now want to add another age group. I've edited the module to include this new age group but can't seem to get it to appear!



    Here is the module code:
    Code:
    Public Function AgeGroup(DoB As Variant) As String
    Dim ageCount As Integer
    Dim intAge As Integer
    If IsNull(DoB) Then
      AgeGroup = "N/A"
      Exit Function
    End If
    intAge = DateDiff("yyyy", [DoB], Now()) + Int(Format(Now(), "mmdd") < Format([DoB], "mmdd"))
    Select Case intAge
    Case Is < 1
    AgeGroup = "A) Under 1"
    Case 1
    AgeGroup = "B) 1 Year"
    Case 2
    AgeGroup = "C) 2 Years"
    Case 3
    AgeGroup = "D) 3 Years"
    Case 4
    AgeGroup = "E) 4 Years"
    Case 5
    AgeGroup = "F) 5 Years"
    Case Else
    AgeGroup = "N/A"
    End Select
    End Function
    and here is the query:

    Code:
    SELECT Count(Child.DoB) AS CountOfDoB, AgeGroup([DOB]) AS [Age Group], totalchildrenunder6.CountOfChildID
    FROM Child, totalchildrenunder6
    GROUP BY AgeGroup([DOB]), totalchildrenunder6.CountOfChildID, Child.AccessedThisQuarter
    HAVING (((AgeGroup([DOB]))<>"N/A") AND ((Child.AccessedThisQuarter)=True));
    It still works but it just does not show the new age group. Any ideas what I've done wrong here?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Which is the new group that doesn't show? Have you set a breakpoint to examine what the code does when you expect that group? What would a birth date be for a person in that group?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Grouping Options
    By Desstro in forum Queries
    Replies: 1
    Last Post: 06-20-2010, 06:33 PM
  2. Grouping query
    By Mphiri in forum Programming
    Replies: 10
    Last Post: 06-15-2010, 08:58 AM
  3. Grouping strings
    By Fre in forum Access
    Replies: 16
    Last Post: 04-24-2010, 03:46 PM
  4. Need help grouping results.
    By cljac in forum Queries
    Replies: 9
    Last Post: 03-24-2010, 10:10 AM
  5. Grouping
    By dref in forum Reports
    Replies: 1
    Last Post: 01-16-2010, 08:30 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