I have 2 fields side by side on a subreport, one contains an eight digit date (char) and the other a quantity of minutes (int). For the 1st field, instead of the date I need to show the corresponding day of the week so the textbox on the report contains this
=getdayofweek([PayDate])
And here's the function
Public Function GetDayOfWeek(InDate As Variant) As Variant
Dim DayNo As Integer
Dim DayName As String
DayNo = WeekDay(Date1(InDate))
Select Case DayNo
Case 1
DayName = "Sunday"
Case 2
DayName = "Monday"
Case 3
DayName = "Tuesday"
Case 4
DayName = "Wednesday"
Case 5
DayName = "Thursday"
Case 6
DayName = "Friday"
Case 7
DayName = "Saturday"
End Select
GetDayOfWeek = DayName
End Function
This works fine, the report shows monday, tuesday etc. Now, its neighbour, the minutes field, needs converting to hours and minutes, so the text box contains
=MinsToHrsMins([OffMins])
And here's the function
Public Function MinsToHrsMins(InMins As Variant) As Variant
' Takes 210 and sends back 0330
On Error GoTo Error_Handler
Dim Hrs As Integer
Dim Mins As Integer
Dim HrsStr As String * 2
Dim MinsStr As String * 2
Hrs = Int(InMins / 60)
Mins = InMins - (Hrs * 60)
HrsStr = Format(Hrs, "00"
MinsStr = Format(Mins, "00"
MinsToHrsMins = HrsStr & ":" & MinsStr
Error_Handler:
End Function
This function never receives the value (Offmins) from the report and consequently always falls thru to the error handler. The function works when called from forms. Can anyone tell me why one function call works and the other doesnt? Its an access project with a sql server database if thats at all relevant.
=getdayofweek([PayDate])
And here's the function
Public Function GetDayOfWeek(InDate As Variant) As Variant
Dim DayNo As Integer
Dim DayName As String
DayNo = WeekDay(Date1(InDate))
Select Case DayNo
Case 1
DayName = "Sunday"
Case 2
DayName = "Monday"
Case 3
DayName = "Tuesday"
Case 4
DayName = "Wednesday"
Case 5
DayName = "Thursday"
Case 6
DayName = "Friday"
Case 7
DayName = "Saturday"
End Select
GetDayOfWeek = DayName
End Function
This works fine, the report shows monday, tuesday etc. Now, its neighbour, the minutes field, needs converting to hours and minutes, so the text box contains
=MinsToHrsMins([OffMins])
And here's the function
Public Function MinsToHrsMins(InMins As Variant) As Variant
' Takes 210 and sends back 0330
On Error GoTo Error_Handler
Dim Hrs As Integer
Dim Mins As Integer
Dim HrsStr As String * 2
Dim MinsStr As String * 2
Hrs = Int(InMins / 60)
Mins = InMins - (Hrs * 60)
HrsStr = Format(Hrs, "00"
MinsStr = Format(Mins, "00"
MinsToHrsMins = HrsStr & ":" & MinsStr
Error_Handler:
End Function
This function never receives the value (Offmins) from the report and consequently always falls thru to the error handler. The function works when called from forms. Can anyone tell me why one function call works and the other doesnt? Its an access project with a sql server database if thats at all relevant.