calculate students current grade based on Birthday (1 Viewer)

ralphyehle

Registered User.
Local time
Today, 07:34
Joined
Aug 28, 2002
Messages
22
Hi,

I want to calculate student's current grade levels based on their birthday.

If todays date is 04/11/2008 then calculate the most recent past September 1st as 09/01/2007, use that September date minus the students birthday, to find age as a whole number and from that, calculate the grade levels, If 5 years old then Kindergarten, if 6 then first grade, etc. all the way up to grade 12.

I hope this is clear?

Ralph
 

Rabbie

Super Moderator
Local time
Today, 07:34
Joined
Jul 10, 2007
Messages
5,906
Hi,

I want to calculate student's current grade levels based on their birthday.

If todays date is 04/11/2008 then calculate the most recent past September 1st as 09/01/2007, use that September date minus the students birthday, to find age as a whole number and from that, calculate the grade levels, If 5 years old then Kindergarten, if 6 then first grade, etc. all the way up to grade 12.

I hope this is clear?

Ralph

Aircode for your problem would be to use the Case statement

Calculate Age
Select Case Age
case 5
Grade = "Kindergarten"
Case 6
Grade = "1st Grade"

and so on
 
D

Deleted member 30250

Guest
Can't I find anything better to do on a Saturday afternoon? This formula worked for me in Excel, it would need 'translating' into Access:

=YEAR(IF(DATE(YEAR(AsOfDate),9,1)>AsOfDate,DATE(YEAR(AsOfDate)-1,9,1),DATE(YEAR(AsOfDate),9,1)))-YEAR(DOB)+IF(MONTH(DOB)>MONTH(IF(DATE(YEAR(AsOfDate),9,1)>AsOfDate,DATE(YEAR(AsOfDate)-1,9,1),DATE(YEAR(AsOfDate),9,1))),1,0)-5

Where AsOfDate could be today, DOB is date of birth. (Kindergarten comes out as zero).
 

missinglinq

AWF VIP
Local time
Today, 02:34
Joined
Jun 20, 2003
Messages
6,423
Here's code I placed in the AfterUpdate event for a control named DOB. It uses a formula that calculates the exact age on a given date, taking into account whether or not the birthday for that year has occurred yet.

Code:
Private Sub DOB_AfterUpdate()
Dim StartDate As Date
Dim Age As Integer

'Determine Start Date for Current School Year
If DateSerial(Year(Date), 9, 1) > Date Then
 StartDate = DateSerial(Year(Date) - 1, 9, 1)
Else
 StartDate = DateSerial(Year(Date), 9, 1)
End If

'Determine Actual Age at Start of Current School Year
Age = DateDiff("yyyy", [DOB], StartDate) - IIf(Format$(StartDate, "mmdd") < Format$([DOB], "mmdd"), 1, 0)

'Determine Grade Based on Actual Age and Assign to Grade Field
Select Case Age
 Case 5
   Me.Grade = "Kindergarden"
 Case 6
   Me.Grade = "First Grade"
 Case 7
   Me.Grade = "Second Grade"
 Case 8
   Me.Grade = "Third Grade"
 Case 9
   Me.Grade = "Fourth Grade"
 Case 10
   Me.Grade = "Fifth Grade"
 Case 11
   Me.Grade = "Sixth Grade"
 Case 12
   Me.Grade = "Seventh Grade"
 Case 13
   Me.Grade = "Eighth Grade"
 Case 14
   Me.Grade = "Ninth Grade"
 Case 15
   Me.Grade = "Tenth Grade"
 Case 16
   Me.Grade = "Eleventh Grade"
 Case 17
   Me.Grade = "Twelfth Grade"
 Case Else
   Me.Grade = "Outside of School Age"
 End Select

End Sub
 
Last edited:

ralphyehle

Registered User.
Local time
Today, 07:34
Joined
Aug 28, 2002
Messages
22
Thanks much to both suggestions. I've got it working now.

Ralph
 

colincliff

New member
Local time
Yesterday, 23:34
Joined
Aug 19, 2009
Messages
3
Hi ralphyehle,

i'm looking for the answer to this too! What expression did you use in the end?

thanks in advance :)
 

Users who are viewing this thread

Top Bottom