N
NewbieSupreme
I have a WorkingDays function that returns number of working days between 2
dates. The code for it follows (as you can see, it uses values entered into
a Holidays table to exclude them as well as Saturdays and Sundays):
Public Function WorkingDays(StartDate As Date, EndDate As Date) As Integer
On Error GoTo Err_WorkingDays
Dim intCount As Integer
Dim rst As DAO.Recordset
Dim DB As DAO.Database
Set DB = CurrentDb
Set rst = DB.OpenRecordset("SELECT [HolDate] FROM Holidays", dbOpenSnapshot)
StartDate = StartDate + 1
intCount = 0
Do While StartDate <= EndDate
rst.FindFirst "[HolDate] = #" & StartDate & "#"
If Weekday(StartDate) <> vbSunday And Weekday(StartDate) <> vbSaturday Then
If rst.NoMatch Then intCount = intCount + 1
End If
StartDate = StartDate + 1
Loop
WorkingDays = intCount
Exit_WorkingDays:
Exit Function
Err_WorkingDays:
Select Case Err
Case Else
MsgBox Err.Description
Resume Exit_WorkingDays
End Select
End Function
I have a query that has two dae fields: DateReceived and DateShipped. I
show these values, and also an expression which is the Working Days between:
Turnaround: WorkingDays([DateReceived],[DateShipped])
When I run the query, everything works fine. However, if I choose
View-->Totals, with all columns set to GroupBy in the Totals row, I suddenly
get a Data Type Mismatch error. Can anyone explain why this would be?
Please remember that it works fine as long as he Totals row is not active.
Thanks for any help.
dates. The code for it follows (as you can see, it uses values entered into
a Holidays table to exclude them as well as Saturdays and Sundays):
Public Function WorkingDays(StartDate As Date, EndDate As Date) As Integer
On Error GoTo Err_WorkingDays
Dim intCount As Integer
Dim rst As DAO.Recordset
Dim DB As DAO.Database
Set DB = CurrentDb
Set rst = DB.OpenRecordset("SELECT [HolDate] FROM Holidays", dbOpenSnapshot)
StartDate = StartDate + 1
intCount = 0
Do While StartDate <= EndDate
rst.FindFirst "[HolDate] = #" & StartDate & "#"
If Weekday(StartDate) <> vbSunday And Weekday(StartDate) <> vbSaturday Then
If rst.NoMatch Then intCount = intCount + 1
End If
StartDate = StartDate + 1
Loop
WorkingDays = intCount
Exit_WorkingDays:
Exit Function
Err_WorkingDays:
Select Case Err
Case Else
MsgBox Err.Description
Resume Exit_WorkingDays
End Select
End Function
I have a query that has two dae fields: DateReceived and DateShipped. I
show these values, and also an expression which is the Working Days between:
Turnaround: WorkingDays([DateReceived],[DateShipped])
When I run the query, everything works fine. However, if I choose
View-->Totals, with all columns set to GroupBy in the Totals row, I suddenly
get a Data Type Mismatch error. Can anyone explain why this would be?
Please remember that it works fine as long as he Totals row is not active.
Thanks for any help.