Use these functions to spell out the date in your reports and forms
Use this function to spell out the current date in your reports and forms.
Public Function GetYearMonthDay() As String
'---------------------------------------------------------------------------------------
' Procedure : GetMonthName
' Author : AccessExperts.net
' This function will return today's month and day in this format. "August 22nd, 2005"
GetYearMonthDay = GetMonthName(month(Date)) & " " & GetDayName(Day(Date)) & ", " & Year(Date)
End Function
Public Function GetMonthName(month As Integer) As String
'---------------------------------------------------------------------------------------
' Procedure : GetMonthName
' Author : AccessExperts.net
' This function returns the month name based on its number.
Select Case month
Case 1
GetMonthName = "January"
Case 2
GetMonthName = "February"
Case 3
GetMonthName = "March"
Case 4
GetMonthName = "April"
Case 5
GetMonthName = "May"
Case 6
GetMonthName = "June"
Case 7
GetMonthName = "July"
Case 8
GetMonthName = "August"
Case 9
GetMonthName = "September"
Case 10
GetMonthName = "October"
Case 11
GetMonthName = "November"
Case 12
GetMonthName = "December"
End Select
On Error GoTo 0
Exit Function
GetMonthName_Error:
msgbox err.description
End Function
Public Function GetDayName(lngDay As Long) As String
' This function will return the day's suffix based on its number. For example: "22nd"
Select Case lngDay
Case 1, 21, 31
GetDayName = lngDay & "st"
Case 2, 22
GetDayName = lngDay & "nd"
Case 3, 23
GetDayName = "3rd"
Case 4 To 20, 24 To 30
GetDayName = lngDay & "th"
End Select
End Function