Originally posted by okosh
If you hard code the holidays into for example a table list of the dates. You could check if at any step in the procedure the date was in the holiday list and move on a day if it is.
Mary
Private Sub OrderDate_AfterUpdate()
Dim tempDate As Date
Dim iCount As Integer
Dim i As Integer
iCount = 0
tempDate = Me.OrderDate
Do Until iCount = 7
tempDate = tempDate + 1
Check_Holidays:
' check if the date is on the holiday table
If Not IsNull(DLookup("HolidayDate","tblHolidays","HolidayDate=" & tempDate)) Then
tempDate = tempDate + 1
GoTo Check_Holidays ' check again on the new date
End If
If Weekday(tempDate) = 7 Then
tempDate = tempDate + 2
End If
iCount = iCount + 1
Loop
Me.NewDate = tempDate
End Sub
Private Sub OrderDate_AfterUpdate()
Dim tempDate As Date
Dim iCount As Integer
Dim i As Integer
iCount = 0
tempDate = Me.OrderDate
Do Until iCount = 7
tempDate = tempDate + 1
Check_Holidays:
' check if the date is on the holiday table
If Not IsNull(DLookup("HolidayDate","tblHolidays","HolidayDate=" & tempDate)) Then
tempDate = tempDate + 1
GoTo Check_Holidays ' check again on the new date
End If
If Weekday(tempDate) = 7 Then
tempDate = tempDate + 2
End If
iCount = iCount + 1
Loop
Me.NewDate = tempDate
End Sub
Private Sub OrderDate_AfterUpdate()
Dim tempDate As Date
Dim iCount As Integer
Dim i As Integer
iCount = 0
tempDate = Me.OrderDate
Do Until iCount = 7
tempDate = tempDate + 1
Check_Holidays:
' check if the date is on the holiday table
If Not IsNull(DLookup("HolidayDate","tblHolidays","HolidayDate=#" & tempDate & "#")) Then
tempDate = tempDate + 1
GoTo Check_Holidays ' check again on the new date
End If
If Weekday(tempDate) = 7 Then
tempDate = tempDate + 2
End If
iCount = iCount + 1
Loop
Me.NewDate = tempDate
End Sub
Comment