I reserve, check-out and check-in equipment that is loaned out to our employees (projectors, microphones, laptops, etc.)
When putting in a date the equipment needs to be picked up, I run it through the following code to ensure we don't reserve for weekends or holidays.
Unfortunately, when testing in the immediate window, it keeps telling me that my date is a saturday and changes it to 1/1/1900 . I'm using 7/4/2014 as my test date.
Thanks, Any help will be greatly appreciated. :banghead:
When putting in a date the equipment needs to be picked up, I run it through the following code to ensure we don't reserve for weekends or holidays.
Unfortunately, when testing in the immediate window, it keeps telling me that my date is a saturday and changes it to 1/1/1900 . I'm using 7/4/2014 as my test date.
Code:
Function HolidayWeekend(vDate) As Integer
'1/1/1900 is the way that Access interprets the numeric value 0 as a date.
HolidayWeekend = False
vDate = Format(vDate, "mm/dd/yyyy")
' Test for Saturday or Sunday.
If Weekday(vDate) = 1 Then
vDate = DateAdd("d", 2, vDate
MsgBox "was sunday " & vDate
HolidayWeekend = True
Exit Function
ElseIf Weekday(vDate) = 7 Then
vDate = DateAdd("d", 2, vDate)
MsgBox "was saturday " & vDate
HolidayWeekend = True
Exit Function
' Test for Holiday.
ElseIf DLookup("[HolidayDate]", "[ltblHolidays]", "[HolidayDate]= " & vDate) Then
MsgBox "Holiday is " '& DLookup("Holidaydate", "ltblHolidays", "[HolidayDate]=" & vDate)
HolidayWeekend = True
'Exit Function
End If
End Function
Thanks, Any help will be greatly appreciated. :banghead: