Stefan53nz
New member
- Local time
- Today, 12:00
- Joined
- May 18, 2013
- Messages
- 4
Hi
I've a club database the records score for juniors on age groups that are set as of the 1st January each year. I would like to set this automatically from the date of birth. I have found some code that is very close to what I need apart from the fact it groups on the exact DOB resulting in changes to age group mid year.
Could someone advise changes require to the code below.
'----------------------------Code Start--------------------------------
Public Function AgeGroup(dtmBirthDate As Date) As String
Dim intAge As Integer
'Age Calculation
intAge = DateDiff("yyyy", [dtmBirthDate], Now()) + _
Int(Format(Now(), "yyyy") < Format([dtmBirthDate], "yyyy"))
Select Case intAge
'For each Age range, write out Age Group (used in qry)
Case 0 To 10
AgeGroup = "Kiwi"
Case 11 To 13
AgeGroup = "Cub"
Case 14 To 15
AgeGroup = "Intermediate"
Case 16 To 17
AgeGroup = "Cadet"
Case 18 To 20
AgeGroup = "Junior"
Case Is > 20
AgeGroup = "Senior"
End Select
End Function
'----------------------------Code End-----------------------------------
Thanks
Stefan
I've a club database the records score for juniors on age groups that are set as of the 1st January each year. I would like to set this automatically from the date of birth. I have found some code that is very close to what I need apart from the fact it groups on the exact DOB resulting in changes to age group mid year.
Could someone advise changes require to the code below.
'----------------------------Code Start--------------------------------
Public Function AgeGroup(dtmBirthDate As Date) As String
Dim intAge As Integer
'Age Calculation
intAge = DateDiff("yyyy", [dtmBirthDate], Now()) + _
Int(Format(Now(), "yyyy") < Format([dtmBirthDate], "yyyy"))
Select Case intAge
'For each Age range, write out Age Group (used in qry)
Case 0 To 10
AgeGroup = "Kiwi"
Case 11 To 13
AgeGroup = "Cub"
Case 14 To 15
AgeGroup = "Intermediate"
Case 16 To 17
AgeGroup = "Cadet"
Case 18 To 20
AgeGroup = "Junior"
Case Is > 20
AgeGroup = "Senior"
End Select
End Function
'----------------------------Code End-----------------------------------
Thanks
Stefan