I added the following module which seemed to work correctly for a few days, but is now causing the query to "lock up" my PC (the query runs forever). Can anyone help me understand why this might be happening? The module is:
Public Function NetWorkdays(dteStart As Date, dteEnd As Date) As Integer
Dim intGrossDays As Integer
Dim dteCurrDate As Date
Dim i As Integer
intGrossDays = DateDiff("d", dteStart, dteEnd)
NetWorkdays = 0
For i = 0 To intGrossDays
dteCurrDate = dteStart + i
If Weekday(dteCurrDate, vbMonday) < 6 Then
If IsNull(DLookup("[HolDate]", "Holidays", "[HolDate] = #" & dteCurrDate & "#")) Then
NetWorkdays = NetWorkdays + 1
End If
End If
Next i
End Function
I use it with a query and the following is in one of the columns:
Fax Date Difference: NetWorkDays([StartDate],[EndDate])
I have a table in the query "Holidays" with the fields Holidays and HolDate.
Any help would be appreciated.
Public Function NetWorkdays(dteStart As Date, dteEnd As Date) As Integer
Dim intGrossDays As Integer
Dim dteCurrDate As Date
Dim i As Integer
intGrossDays = DateDiff("d", dteStart, dteEnd)
NetWorkdays = 0
For i = 0 To intGrossDays
dteCurrDate = dteStart + i
If Weekday(dteCurrDate, vbMonday) < 6 Then
If IsNull(DLookup("[HolDate]", "Holidays", "[HolDate] = #" & dteCurrDate & "#")) Then
NetWorkdays = NetWorkdays + 1
End If
End If
Next i
End Function
I use it with a query and the following is in one of the columns:
Fax Date Difference: NetWorkDays([StartDate],[EndDate])
I have a table in the query "Holidays" with the fields Holidays and HolDate.
Any help would be appreciated.