show the players age, calculated.... E.g. Joe Bloke , Grimsby 62 Years
The age is easy. There are lots of functions to calculate ages. This is the one I use:
Code:
Function fGetAge(varDOB As Variant, Optional varAsOf As Variant) As Variant
'Purpose: Return the Age in years.
'Arguments: varDOB = Date Of Birth
' varAsOf = the date to calculate the age at, or today if missing.
'Returns: Whole number of years.
Dim dtDOB As Date
Dim dtAsOf As Date
Dim dtBDay As Date 'Birthday in the year of calculation.
fGetAge = Null 'Initialize to Null
'Validate parameters
If IsDate(varDOB) Then
dtDOB = varDOB
If Not IsDate(varAsOf) Then 'Date to calculate age from.
dtAsOf = Date
Else
dtAsOf = varAsOf
End If
If dtAsOf >= dtDOB Then 'Calculate only if it's after person was born.
dtBDay = DateSerial(Year(dtAsOf), Month(dtDOB), Day(dtDOB))
fGetAge = DateDiff("yyyy", dtDOB, dtAsOf) + (dtBDay > dtAsOf)
End If
End If
End Function
I have a module named "modCalculations" that I keep functions in.
Usage:
Code:
=Nz([Student Name],"Untitled") & " " & IIf(IsNull([StudAge]),"",[StudAge] & " years")
(I really hate spaces in object names!!)
I modified the query "Students Extended" - added the function to calc the age.
I don't see where the "nick name" is stored.
-------------------------------------------
And another question please, about adding the relationship "brother" or "father" ...
I modified the dB that I have (not the most recent version). Easier to show you than write....
I created 3 tables: "MedicalInfo", "tblRelationships" and "tblRelatives".
Created 3 sub forms: "sfMedicalInfo" and "sfRelatives".
Added sub form "sfMedicalInfo" to the "Medical Information" tab.
Added sub form "sfRelatives" to the student details form.
Added age to the name on the student details form.
I've been testing/using the student "dff fggg".....
(hope this is close to what you are wanting.... )