I'm creating a public function which determines if the selected date is a holiday or else which day it is.
But It don't works correctly. I have made a table Holidays, with the fields HolidayName, Startdate, End Date:
Somehow this will return always the number 8, and haven't figured out where I went wrong.
Please help to get this work, correctly
But It don't works correctly. I have made a table Holidays, with the fields HolidayName, Startdate, End Date:
Code:
Public Function DagNumber(SelectedDate As Date)
'The following values have to be returned:
'Sunday - 1
'Monday - 2
'Tuesday - 3
'Wednesday - 4
'Thursday - 5
'Friday - 6
'Saturday - 7
'Holiday - 8
If Not Nz(DayNumber = DLookup("ID", "Holidays", "#" & SelectedDate & "# BETWEEN [StartDate] AND [EndDate] "), 0) Then
DayNumber = 8
Else
DayNumber is Weekday(SelectedDate)
End Function
Somehow this will return always the number 8, and haven't figured out where I went wrong.
Please help to get this work, correctly