I have a query where I am trying to convert a test date into the academic year in which it occurs.
Here is the code module:
When I run the query, the field AcademicYr is blank. Why is this not working?
Thank you.
Code:
SELECT qryTestingMostRecentTest1.StudentID, qryTestingMostRecentTest1.LastTestDate, qryTestingMostRecentTest1.PrevTestDate, TestToAcademicYr([LastTestDate]) AS AcademicYr
FROM qryTestingMostRecentTest1
GROUP BY qryTestingMostRecentTest1.StudentID, qryTestingMostRecentTest1.LastTestDate, qryTestingMostRecentTest1.PrevTestDate;
Here is the code module:
Code:
Option Compare Database
Public Function TestToAcademicYr(LastTestDate As Date) As String
Dim AcademicYr As String
If LastTestDate >= #7/1/2015# And LastTestDate <= #6/30/2016# Then
AcademicYr = "2015-16"
ElseIf LastTestDate >= #7/1/2016# And LastTestDate <= #6/30/2017# Then
AcademicYr = "2016-17"
ElseIf LastTestDate >= #7/1/2017# And LastTestDate <= #6/30/2018# Then
AcademicYr = "2017-18"
ElseIf LastTestDate >= #7/1/2018# And LastTestDate <= #6/30/2019# Then
AcademicYr = "2018-19"
ElseIf LastTestDate >= #7/1/2019# And LastTestDate <= #6/30/2020# Then
AcademicYr = "2019-20"
End If
End Function
When I run the query, the field AcademicYr is blank. Why is this not working?
Thank you.