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?