S
Stefan
Hi All
I’m trying to modify the famous weekday calculation from
http://www.mvps.org/access/datetime/date0006.htm
But I have a problem, I have a StartDate and I want to add ActiveDays
instead of an EndDate. But it returns nothing.
Public Function EndDate(StartDate As Date, ActiveDays As Integer) As Date
Dim intCount As Integer
Dim rst As DAO.Recordset
Dim DB As DAO.Database
Set DB = CurrentDb
Set rst = DB.OpenRecordset("SELECT [HolidayDate] FROM tblHolidays",
dbOpenSnapshot)
intCount = 0
Do While intCount <= ActiveDays
rst.FindFirst "[HolidayDate] = #" & StartDate & "#"
If Weekday(StartDate) <> vbSunday And Weekday(StartDate) <> vbSaturday Then
If rst.NoMatch Then intCount = intCount + 1
End If
StartDate = StartDate + 1
Loop
End Function
Do anyone know what I have done wrong.
Thanks
Stefan
I’m trying to modify the famous weekday calculation from
http://www.mvps.org/access/datetime/date0006.htm
But I have a problem, I have a StartDate and I want to add ActiveDays
instead of an EndDate. But it returns nothing.
Public Function EndDate(StartDate As Date, ActiveDays As Integer) As Date
Dim intCount As Integer
Dim rst As DAO.Recordset
Dim DB As DAO.Database
Set DB = CurrentDb
Set rst = DB.OpenRecordset("SELECT [HolidayDate] FROM tblHolidays",
dbOpenSnapshot)
intCount = 0
Do While intCount <= ActiveDays
rst.FindFirst "[HolidayDate] = #" & StartDate & "#"
If Weekday(StartDate) <> vbSunday And Weekday(StartDate) <> vbSaturday Then
If rst.NoMatch Then intCount = intCount + 1
End If
StartDate = StartDate + 1
Loop
End Function
Do anyone know what I have done wrong.
Thanks
Stefan