Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / April 2008

Tip: Looking for answers? Try searching our database.

Calculate current school grade level

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ralph - 12 Apr 2008 17:04 GMT
I want to create a field on a form that will look at the child's birthdate
and calculate their school year (kindergarten through 12) based on their age
as of September of the current year. Example, today is April 11, 2008, I
would like the grade to be as of September 1, 2007.

Something like: If today is (whatever the date) then September 1 of the
prior year, minus the students birthdate = an integer rounded down, then 5 =
Kindergarten, 6 = first grade, 7 = second grade, etc., up to 12th grade.

Thank you in advance for any help.

Ralph
Wolfgang Kais - 13 Apr 2008 23:27 GMT
Hello Ralph.

> I want to create a field on a form that will look at the child's
> birthdate and calculate their school year (kindergarten through 12)
[quoted text clipped - 6 lines]
> rounded down, then 5 = Kindergarten, 6 = first grade, 7 = second
> grade, etc., up to 12th grade.

You could use a function like this (in a standard module):

Option Compare Database
Option Explicit

Function SchoolYear(Birthdate As Date) As String

   Dim September1st As Date, Today As Date
   Dim Birthday As Date
   Dim AgeOnSeptember1st As Integer

   Today = Date
   September1st = DateSerial(Year(Today), 9, 1)
   If September1st > Today Then
       September1st = DateAdd("yyyy", -1, September1st)
   End If
   AgeOnSeptember1st = DateDiff("yyyy", Birthdate, September1st)
   Birthday = DateAdd("yyyy", AgeOnSeptember1st, Birthdate)
   If Birthday > September1st Then
       AgeOnSeptember1st = AgeOnSeptember1st - 1
   End If
   Select Case AgeOnSeptember1st
       Case Is < 5
           SchoolYear = "too young for school"
       Case 5
           SchoolYear = "Kindergarten"
       Case 6
           SchoolYear = "first grade"
       Case 7
           SchoolYear = "second grade"
       Case 8
           SchoolYear = "third grade"
       Case 9 To 17
           SchoolYear = CStr(AgeOnSeptember1st - 5) & "th grade"
       Case Else
           SchoolYear = "too old for school"
   End Select

End Function

Signature

Regards,
Wolfgang

Ken Snell (MVP) - 13 Apr 2008 23:27 GMT
You could use an expression similar to this as the Control Source for a
textbox on the form (I'm using generic name for BirthDate field, which I
assume is in the form's Record Source query):

=DateDiff("yyyy",[BirthDate],DateSerial(Year(Date())+(Format(Date(),"mmdd")<"0901"),9,1))-5

You will get a 0 from the above expression for Kindergarten grade. If you
want to show Kindergarten as the grade in that situation, use the text box's
Format property:
   ;;"Kindergarten"

Signature

       Ken Snell
<MS ACCESS MVP>

>I want to create a field on a form that will look at the child's birthdate
> and calculate their school year (kindergarten through 12) based on their
[quoted text clipped - 10 lines]
>
> Ralph
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.