Hi
On my form, I use this date function
Option Compare Database
Option Explicit
Function AddWkDays(vardate As Variant, numdays As Integer, _
pexclude As String)
'*******************************************
'Name: AddWkDays (Function)
'Purpose: Simple, non-formula method of
' adding weekdays to a given
' date
'Inputs: ? AddWkdays("08/04/94", 10, "17")
'Output: 8/18/1994
'Note: pexclude = the weekdays to exclude
' (e.g., Sat = 7, Sunday = 1)
'*******************************************
Dim thedate As Date, n As Integer, incl As Boolean
thedate = DateValue(vardate)
incl = False
Do While InStr(pexclude, WeekDay((thedate) + 1)) > 0
thedate = thedate + 1
incl = True
Loop
thedate = thedate + IIf(incl = False, 1, 0)
n = 0
Do While n < numdays
If InStr(pexclude, WeekDay(thedate)) = 0 Then
n = n + 1
End If
If n = numdays Then Exit Do
thedate = thedate + 1
Loop
AddWkDays = thedate
End Function
I put it into the separate module and call whenever I need it.
Works well on my workstation.
But doesn't work on any other (database is on our sharedrive)
Any suggestions?
Thanks
On my form, I use this date function
Option Compare Database
Option Explicit
Function AddWkDays(vardate As Variant, numdays As Integer, _
pexclude As String)
'*******************************************
'Name: AddWkDays (Function)
'Purpose: Simple, non-formula method of
' adding weekdays to a given
' date
'Inputs: ? AddWkdays("08/04/94", 10, "17")
'Output: 8/18/1994
'Note: pexclude = the weekdays to exclude
' (e.g., Sat = 7, Sunday = 1)
'*******************************************
Dim thedate As Date, n As Integer, incl As Boolean
thedate = DateValue(vardate)
incl = False
Do While InStr(pexclude, WeekDay((thedate) + 1)) > 0
thedate = thedate + 1
incl = True
Loop
thedate = thedate + IIf(incl = False, 1, 0)
n = 0
Do While n < numdays
If InStr(pexclude, WeekDay(thedate)) = 0 Then
n = n + 1
End If
If n = numdays Then Exit Do
thedate = thedate + 1
Loop
AddWkDays = thedate
End Function
I put it into the separate module and call whenever I need it.
Works well on my workstation.
But doesn't work on any other (database is on our sharedrive)
Any suggestions?
Thanks