G
Guest
Hi All,
I'm trying to put together a function that will look at a date and determine
whether or not it's a "working day" (ie not a weekend or public holiday).
I've got a table (tblHolidays) with a field (HolDate) that contains a list
of public holidays. I want to compare the date (dtmTemp) with the values in
HolDate to see if it's a working day or not.
Here's the code I've come up with so far, borrowed and adapted from various
similar threads. However, I'm getting a "run-time error (3085) undefined
function 'dtmtemp' in expression".
This is undoubtedly an easy one for the experienced hands, but I wouldn't
fall into that category, more's the pity...
Public Function IsWorkingDay(dtmTemp As Date) As Boolean
Dim rsHolidays As Recordset
If Weekday(dtmTemp) = 7 Or Weekday(dtmTemp) = 1 Then IsWorkingDay = False
Set rsHolidays = CurrentDb.OpenRecordset("SELECT [HolDate] FROM tblHolidays
Where [HolDate] = dtmTemp()", dbOpenSnapshot)
If not rsHolidays.BOF And rsHolidays.EOF Then
IsWorkingDay = True
Else
IsWorkingDay = False
End If
rsHolidays.Close
Set rsHolidays = Nothing
End Function
I'm trying to put together a function that will look at a date and determine
whether or not it's a "working day" (ie not a weekend or public holiday).
I've got a table (tblHolidays) with a field (HolDate) that contains a list
of public holidays. I want to compare the date (dtmTemp) with the values in
HolDate to see if it's a working day or not.
Here's the code I've come up with so far, borrowed and adapted from various
similar threads. However, I'm getting a "run-time error (3085) undefined
function 'dtmtemp' in expression".
This is undoubtedly an easy one for the experienced hands, but I wouldn't
fall into that category, more's the pity...
Public Function IsWorkingDay(dtmTemp As Date) As Boolean
Dim rsHolidays As Recordset
If Weekday(dtmTemp) = 7 Or Weekday(dtmTemp) = 1 Then IsWorkingDay = False
Set rsHolidays = CurrentDb.OpenRecordset("SELECT [HolDate] FROM tblHolidays
Where [HolDate] = dtmTemp()", dbOpenSnapshot)
If not rsHolidays.BOF And rsHolidays.EOF Then
IsWorkingDay = True
Else
IsWorkingDay = False
End If
rsHolidays.Close
Set rsHolidays = Nothing
End Function