All it is trying to do is to find an age group value based on a date of birth (eg "U15", or "senior"). The base table has fields: agegroup_id : auto, agegroup : text, agegroup_oldest : date/time.
Expand|Select|Wrap|Line Numbers
- Function AgeGroup(aDate As Date) As String
- 'This function takes an argument aDate as athlete's date of birth and looks up the textual age group
- Dim tempvar As String
- Dim qdf As QueryDef
- Dim rst As Recordset
- Dim qdf1 As QueryDef
- Dim rst1 As Recordset
- Set qdf = CurrentDb.CreateQueryDef("", "SELECT T1.agegroup FROM t_agegroup AS T1 WHERE T1.agegroup_oldest =(SELECT Min(T2.agegroup_oldest)FROM t_agegroup AS T2 WHERE T2.agegroup_oldest>=[value];);")
- qdf.Parameters("Value") = (aDate)
- Set rst = qdf.OpenRecordset
- If rst.RecordCount > 0 Then tempvar = rst!AgeGroup
- rst.Close
- AgeGroup = tempvar
- End Function
Any thoughts greatly appreciated.
Thanks