9
904allen
I have been developing a program for the investigators in our department to
use. This is not part of my job I just wanted to see if I could do it. While
I have to say I put together a slick program and its all do to the
information and help I received from all of you here. Thank You and keep up
the good work. I have one more task I want to be able to set alerts on the
opening form to let the investigator know that they have to do something on a
case but I need to be able to set work days on the case form. I have several
dates that are updated and when the time expires the investigator needs to
work the file. So my final request is help in this last area. In reading one
of the many post over the last several weeks I came across this function by
Dave Hargis, which I copied and put into my program. But I don’t know how to
implement it. Can you help.
Public Function AddWorkDays(OriginalDate As Date, DaysToAdd As Integer) As
Date
'D Hargis
'OriginalDate = First Day to calculate number of working days from
'DaysToAdd = Number of Working Days to add to OriginalDate
'Returns the date that is the last working day for the number of days
'To look back, pass a negative number of days
'If 0 is entered, the current date is returned
Dim intDayCount As Integer
Dim dtmReturnDate As Date
Dim intAdd As Integer
'Determine whether to add or subtract
Select Case DaysToAdd
Case Is >= 1
intAdd = 1
Case Is = 0
AddWorkDays = OriginalDate
Exit Function
Case Else
intAdd = -1
End Select
intDayCount = 0
Do While True
If Weekday(OriginalDate, vbMonday) <= 5 Then 'It is a weekday
If IsNull(DLookup("[HolDate]", "Holidays", _
"[HolDate] = #" & OriginalDate & "#")) Then
intDayCount = intDayCount + intAdd
dtmReturnDate = OriginalDate
End If
End If
If intDayCount = DaysToAdd Then
Exit Do
End If
OriginalDate = DateAdd("d", intAdd, OriginalDate)
Loop
AddWorkDays = dtmReturnDate
End Function
use. This is not part of my job I just wanted to see if I could do it. While
I have to say I put together a slick program and its all do to the
information and help I received from all of you here. Thank You and keep up
the good work. I have one more task I want to be able to set alerts on the
opening form to let the investigator know that they have to do something on a
case but I need to be able to set work days on the case form. I have several
dates that are updated and when the time expires the investigator needs to
work the file. So my final request is help in this last area. In reading one
of the many post over the last several weeks I came across this function by
Dave Hargis, which I copied and put into my program. But I don’t know how to
implement it. Can you help.
Public Function AddWorkDays(OriginalDate As Date, DaysToAdd As Integer) As
Date
'D Hargis
'OriginalDate = First Day to calculate number of working days from
'DaysToAdd = Number of Working Days to add to OriginalDate
'Returns the date that is the last working day for the number of days
'To look back, pass a negative number of days
'If 0 is entered, the current date is returned
Dim intDayCount As Integer
Dim dtmReturnDate As Date
Dim intAdd As Integer
'Determine whether to add or subtract
Select Case DaysToAdd
Case Is >= 1
intAdd = 1
Case Is = 0
AddWorkDays = OriginalDate
Exit Function
Case Else
intAdd = -1
End Select
intDayCount = 0
Do While True
If Weekday(OriginalDate, vbMonday) <= 5 Then 'It is a weekday
If IsNull(DLookup("[HolDate]", "Holidays", _
"[HolDate] = #" & OriginalDate & "#")) Then
intDayCount = intDayCount + intAdd
dtmReturnDate = OriginalDate
End If
End If
If intDayCount = DaysToAdd Then
Exit Do
End If
OriginalDate = DateAdd("d", intAdd, OriginalDate)
Loop
AddWorkDays = dtmReturnDate
End Function