I am attempting to create a function that will adjust an entered date so as to adjust for weekends or holidays. What have I done incorrectly, that the adjusted date does not pass from the function to the subroutine?
Private Sub DATE_ENTERED_AfterUpdate()
Me!DATE_ENTERED = DATE_ADJUST(Me!DATE_ENTERED)
End Sub
Public Function DATE_ADJUST(ByRef INITIAL_DATE As Date)
StartLoop:
'/ if Saturday, add 2 days
If Weekday(INITIAL_DATE) = 7 Then
INITIAL_DATE = INITIAL_DATE + 2
End If
'/ if Sunday, add 1 day
If Weekday(INITIAL_DATE) = 1 Then
INITIAL_DATE = INITIAL_DATE + 1
End If
'/ if CAVC closing date, add 1 day and loop
If Not (IsNull(DLookup("[CAVC closing date]", "[CAVC closing dates]", "[CAVC closing date] = #" & INITIAL_DATE & "#"))) Then
INITIAL_DATE = INITIAL_DATE + 1
GoTo StartLoop
End If
End Function