I'm trying to use a value returned by a function I wrote as the control source in a report text box. I've verified that the function works and displayed the return calue with msgbox just before the end of the function. The value looks correct inside the function but the text box printed on the report displays zero. I've included the function (determines the number of weekdays in a month) as well as the control source definition for the text box. Any help / advice would be deeply appreciated.
control source definition:
=EeTime_WorkDaysInMonth(1,Year(Date()))
Function source code:
Public Function EeTime_WorkDaysInMonth(Mon As Integer, Yr As Integer) As Integer
Dim intFirstOfMonthWeekDay As Integer
Dim intDaysInMonth As Integer
Dim LeapYear As Boolean
On Error GoTo Err_EeTime_WorkDaysInMonth
intFirstOfMonthWeekDay = Weekday(DateSerial(Yr, Mon, 1))
LeapYear = IsDate("2/29/" & Yr)
EeTimeWorkDaysInMonth = 20
If Mon = 1 Then intDaysInMonth = 31
If Mon = 2 And LeapYear = True Then intDaysInMonth = 29
If Mon = 2 And LeapYear = False Then intDaysInMonth = 28
If Mon = 3 Then intDaysInMonth = 31
If Mon = 4 Then intDaysInMonth = 30
If Mon = 5 Then intDaysInMonth = 31
If Mon = 6 Then intDaysInMonth = 30
If Mon = 7 Then intDaysInMonth = 31
If Mon = 8 Then intDaysInMonth = 31
If Mon = 9 Then intDaysInMonth = 30
If Mon = 10 Then intDaysInMonth = 31
If Mon = 11 Then intDaysInMonth = 30
If Mon = 12 Then intDaysInMonth = 31
If intDaysInMonth = 29 Then
EeTimeWorkDaysInMonth = 21
If intFirstOfMonthWeekDay = vbSunday Then EeTimeWorkDaysInMonth = 20
If intFirstOfMonthWeekDay = vbSaturday Then EeTimeWorkDaysInMonth = 20
End If
If intDaysInMonth = 30 Then
EeTimeWorkDaysInMonth = 22
If intFirstOfMonthWeekDay = vbSunday Then EeTimeWorkDaysInMonth = 21
If intFirstOfMonthWeekDay = vbFriday Then EeTimeWorkDaysInMonth = 21
If intFirstOfMonthWeekDay = vbSaturday Then EeTimeWorkDaysInMonth = 20
End If
If intDaysInMonth = 31 Then
EeTimeWorkDaysInMonth = 23
If intFirstOfMonthWeekDay = vbSunday Then EeTimeWorkDaysInMonth = 22
If intFirstOfMonthWeekDay = vbThursday Then EeTimeWorkDaysInMonth = 22
If intFirstOfMonthWeekDay = vbFriday Then EeTimeWorkDaysInMonth = 21
If intFirstOfMonthWeekDay = vbSaturday Then EeTimeWorkDaysInMonth = 21
End If
GoTo GracefulExit_EeTime_WorkDaysInMonth
Err_EeTime_WorkDaysInMonth:
MsgBox "EeTime_WorkDaysInMonth ERROR: " & Err.Description
GracefulExit_EeTime_WorkDaysInMonth:
MsgBox "EeTime_WorkDaysInMonth Graceful Exit: " & EeTimeWorkDaysInMonth
End Function