Hi.
after I copy a schedule template to a new schedule I want to be able to
extend the finish date if a weekend creeps in... otherwise maintain the same
number of working days. Any good way to do this?
Several VBA Workday functions have been published on the Web that may be of
help, particularly the one for counting work days and IsWeekend( ) for
checking for weekends. Please see the following Web pages:
http://www.mvps.org/access/datetime/date0006.htm
http://www.mvps.org/access/datetime/date0012.htm
You can also use the following function to push out a weekend end date to
land on the following Monday:
Public Function calcEndDate(dt As Date) As Date
On Error GoTo ErrHandler
If (Weekday(dt, vbSunday) = vbSaturday) Then
calcEndDate = DateAdd("d", 2, dt)
ElseIf (Weekday(dt, vbSunday) = vbSunday) Then
calcEndDate = DateAdd("d", 1, dt)
Else
calcEndDate = dt
End If
Exit Function
ErrHandler:
MsgBox "Error in calcEndDate( )." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
Err.Clear
calcEndDate = dt
End Function
HTH.
Gunny
See
http://www.QBuilt.com for all your database needs.
See
http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.